From 4ff6491c8641910fcd93986538cc78be392c5576 Mon Sep 17 00:00:00 2001 From: spoukke Date: Fri, 24 Feb 2023 17:19:50 +0100 Subject: [PATCH 1/2] ci: handle tag event --- .github/workflows/ci.yaml | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 914e3ab4..de215243 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - v* pull_request: branches: - main @@ -29,10 +31,8 @@ jobs: - name: Checkout uses: actions/checkout@v3 - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v2 - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Login to GHCR uses: docker/login-action@v2 @@ -40,20 +40,11 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get version from main branch - if: ${{ github.event_name == 'push' }} - run: | - echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV - - - name: Get version from pull request - if: ${{ github.event_name == 'pull_request' }} - run: | - echo "VERSION=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV - - name: Get Build timestamp + - name: Get Build timestamp and branch name run: | echo "BUILD_TIMESTAMP=$(date +'%s')" >> $GITHUB_ENV + echo "VERSION=$( echo ${{ github.head_ref || github.ref_name }} | tr '/' '-' )" >> $GITHUB_ENV - name: Build and push uses: docker/build-push-action@v3 @@ -62,7 +53,7 @@ jobs: build-args: | VERSION=${{ env.VERSION }} BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }} - COMMIT_HASH=${{ env.VERSION }} + COMMIT_HASH=${{ github.sha }} tags: | - ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${{ env.VERSION }} + ghcr.io/${{ github.repository }}:${{ github.sha }} From 30597a90ab5d99f65b38fb162ebebe3a9a4b66ef Mon Sep 17 00:00:00 2001 From: spoukke Date: Fri, 24 Feb 2023 17:20:01 +0100 Subject: [PATCH 2/2] ci: add release workflow --- .github/workflows/release.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..dc0d1ef6 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,14 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + with: + release-type: go