Merge pull request #47 from heyhusen/v2 #152
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
branches: | |
- "main" | |
jobs: | |
pretest: | |
name: Test (with Dockerfile) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Update action.yml to build locally | |
run: | | |
sed -i 's/.*image\:.*/ image\: \"Dockerfile\"/' action.yml | |
cat action.yml | |
- name: Get sample PKGBUILD | |
run: wget https://github.com/${{ github.repository_owner }}/plenti-bin/raw/f5ffaaee02a2119aa16f6b7a27e87e198e096b47/PKGBUILD | |
- name: Running test | |
uses: ./ | |
with: | |
pkgver: '0.4.26' | |
pkgrel: 2 | |
updpkgsums: true | |
srcinfo: true | |
- name: Show diff | |
run: | | |
ls -la | |
git diff PKGBUILD | |
git diff .SRCINFO | |
publish: | |
name: Publish OCI image | |
needs: pretest | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Log in to ghcr.io | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: OCI metadata | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
type=edge,branch=main | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Build image | |
id: build | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
containerfiles: | | |
./Dockerfile | |
extra-args: | | |
--pull | |
- name: Push to ghcr.io | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
image: ${{ steps.build.outputs.image }} | |
tags: ${{ steps.build.outputs.tags }} | |
registry: ghcr.io | |
extra-args: | | |
--disable-content-trust | |
test: | |
name: Test (with prebuilt OCI Image) | |
needs: publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get sample PKGBUILD | |
run: wget https://github.com/${{ github.repository_owner }}/plenti-bin/raw/f5ffaaee02a2119aa16f6b7a27e87e198e096b47/PKGBUILD | |
- name: Update action.yml to use edge tagged container image | |
if: github.ref == 'refs/heads/main' | |
run: | | |
REPOSITORY_OWNER=${{ github.repository_owner }} | |
REPOSITORY_OWNER=$(echo $REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]') | |
REPOSITORY_NAME=${{ github.event.repository.name }} | |
REPOSITORY_NAME=$(echo $REPOSITORY_NAME | tr '[:upper:]' '[:lower:]') | |
sed -i "s/.*image\:.*/ image\: \"docker\:\/\/ghcr.io\/${REPOSITORY_OWNER}\/${REPOSITORY_NAME}\:edge\"/" action.yml | |
cat action.yml | |
- name: Running test | |
uses: ./ | |
with: | |
pkgver: '0.4.26' | |
pkgrel: 2 | |
updpkgsums: true | |
srcinfo: true | |
- name: Show diff | |
run: | | |
ls -la | |
git diff PKGBUILD | |
git diff .SRCINFO | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: test | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get branch/tag names | |
id: branch-name | |
uses: tj-actions/branch-names@v8 | |
with: | |
strip_tag_prefix: "v" | |
- name: Read changelog | |
id: changelog-reader | |
uses: mindsers/changelog-reader-action@v2 | |
with: | |
version: ${{ steps.branch-name.outputs.tag }} | |
path: ./CHANGELOG.md | |
- name: Create/update release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: v${{ steps.branch-name.outputs.tag }} | |
name: v${{ steps.branch-name.outputs.tag }} | |
body: ${{ steps.changelog-reader.outputs.changes }} | |
allowUpdates: true | |
token: ${{ secrets.GITHUB_TOKEN }} |