From 64b027c73979fa38704d6fdfe6c2acd070f68e0b Mon Sep 17 00:00:00 2001 From: Alex Graf Date: Wed, 27 Mar 2024 17:20:05 +0100 Subject: [PATCH] update release action --- .github/actions/create-image/action.yaml | 5 ++++- .github/workflows/dev-deploy.yml | 6 ++++-- .github/workflows/pre-release.yml | 10 ++++++---- .github/workflows/release.yml | 22 +++++++++++----------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/actions/create-image/action.yaml b/.github/actions/create-image/action.yaml index 2a4917fa..102fed2d 100644 --- a/.github/actions/create-image/action.yaml +++ b/.github/actions/create-image/action.yaml @@ -16,6 +16,9 @@ inputs: LATEST: description: 'The latest tag of the image' required: true + CACHE: + description: 'The cache tag of the image' + required: true DOCKERFILE: description: 'The path to the Dockerfile' required: true @@ -68,5 +71,5 @@ runs: REVISION=${{ env.REVISION }} tags: ${{ steps.meta-data.outputs.tags }} labels: ${{ steps.meta-data.outputs.labels }} - cache-from: type=registry,ref=${{ inputs.IMAGE_NAME }}:${{ inputs.TAG }} + cache-from: type=registry,ref=${{ inputs.IMAGE_NAME }}:${{ inputs.CACHE }} cache-to: type=inline diff --git a/.github/workflows/dev-deploy.yml b/.github/workflows/dev-deploy.yml index fae14617..66b25925 100644 --- a/.github/workflows/dev-deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -28,7 +28,8 @@ jobs: IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-app VERSION: ${{ env.VERSION }} PREFIX: e - TAG: type=edge + TAG: edge + CACHE: e${{ env.VERSION }} LATEST: false DOCKERFILE: ./apps/client-asset-sg/docker/Dockerfile TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -39,7 +40,8 @@ jobs: IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-api VERSION: ${{ env.VERSION }} PREFIX: e - TAG: type=edge + TAG: edge + CACHE: e${{ env.VERSION }} LATEST: false DOCKERFILE: ./apps/server-asset-sg/docker/Dockerfile TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index d0b840c6..7fe4a1a8 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -24,8 +24,9 @@ jobs: with: IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-app VERSION: ${{ env.VERSION }} - PREFIX: rc + PREFIX: v TAG: release-candidate + CACHE: edge LATEST: false DOCKERFILE: ./apps/client-asset-sg/docker/Dockerfile TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -35,8 +36,9 @@ jobs: with: IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-api VERSION: ${{ env.VERSION }} - PREFIX: rc + PREFIX: v TAG: release-candidate + CACHE: edge LATEST: false DOCKERFILE: ./apps/server-asset-sg/docker/Dockerfile TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -45,8 +47,8 @@ jobs: id: create_release uses: actions/create-release@v1 with: - tag_name: ${{ env.VERSION }} - release_name: ${{ env.VERSION }} + tag_name: v${{ env.VERSION }} + release_name: v${{ env.VERSION }} body_path: CHANGELOG.md commitish: develop prerelease: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fddf14a4..109577df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,16 +1,14 @@ name: release on: - release: - types: [released] workflow_dispatch: inputs: - TAG_NAME: - description: "Tag Name" + VERSION: + description: "Version number (e.g. 1.2.3)" required: true env: - TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} + VERSION: ${{ github.event.inputs.VERSION }} BASE_IMAGE_NAME: ghcr.io/geoadmin/swissgeol-assets GH_TOKEN: ${{ github.token }} @@ -28,9 +26,10 @@ jobs: uses: ./.github/actions/create-image with: IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-app - VERSION: ${{ env.TAG_NAME }} + VERSION: ${{ env.VERSION }} PREFIX: v TAG: release + CACHE: release-candidate LATEST: true DOCKERFILE: ./apps/client-asset-sg/docker/Dockerfile TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -39,9 +38,10 @@ jobs: uses: ./.github/actions/create-image with: IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-api - VERSION: ${{ env.TAG_NAME }} + VERSION: ${{ env.VERSION }} PREFIX: v TAG: release + CACHE: release-candidate LATEST: true DOCKERFILE: ./apps/server-asset-sg/docker/Dockerfile TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -56,9 +56,9 @@ jobs: - name: Set environment variables run: | - echo GIT_BRANCH_NAME=mark-version-${TAG_NAME#v}-as-released >> $GITHUB_ENV - echo GIT_COMMIT_MESSAGE=Mark version ${TAG_NAME#v} as released >> $GITHUB_ENV - echo RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME} | jq '.id') >> $GITHUB_ENV + echo GIT_BRANCH_NAME=mark-version-${VERSION#v}-as-released >> $GITHUB_ENV + echo GIT_COMMIT_MESSAGE=Mark version ${VERSION#v} as released >> $GITHUB_ENV + echo RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION} | jq '.id') >> $GITHUB_ENV - name: Get changelog for this specific release and update release notes run: | @@ -71,7 +71,7 @@ jobs: - name: Checkout new branch and patch changelog run: | git checkout -b $GIT_BRANCH_NAME - sed -i "/^\#\# \[Unreleased\]$/a \\\n\#\# $TAG_NAME - $(date '+%Y-%m-%d')" CHANGELOG.md + sed -i "/^\#\# \[Unreleased\]$/a \\\n\#\# $VERSION - $(date '+%Y-%m-%d')" CHANGELOG.md - name: Commit, push and create pull request run: |