From 863addce39b36f27a96c303b48c0c0c21320fdaa Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Mon, 23 Jun 2025 03:08:03 -0700 Subject: [PATCH] ci: update release workflow; automatic versioning --- .github/workflows/deploy-docker-github.yml | 100 ++++++++++++--------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/.github/workflows/deploy-docker-github.yml b/.github/workflows/deploy-docker-github.yml index 8221ae7e..bc37c114 100755 --- a/.github/workflows/deploy-docker-github.yml +++ b/.github/workflows/deploy-docker-github.yml @@ -62,18 +62,6 @@ on: default: 'tvapp2' type: string - # # - # Image Version - # - # used to create new release tag, and add version to docker image name - # # - - IMAGE_VERSION: - description: '🏷️ Image Version' - required: true - default: '1.0.0' - type: string - # # # Registry Name # @@ -162,8 +150,7 @@ on: env: IMAGE_NAME: ${{ github.event.inputs.IMAGE_NAME || 'tvapp2' }} - IMAGE_VERSION: ${{ github.event.inputs.IMAGE_VERSION || '1.0.0' }} - IMAGE_REGISTRY: ${{ github.event.inputs.IMAGE_VERSION || 'github' }} + IMAGE_REGISTRY: ${{ github.event.inputs.IMAGE_REGISTRY || 'github' }} IMAGE_GHCR_AUTHOR: ${{ github.event.inputs.IMAGE_GHCR_AUTHOR || 'BinaryNinja' }} IMAGE_GHCR_USERNAME: ${{ github.event.inputs.IMAGE_GHCR_USERNAME || 'BinaryNinja' }} IMAGE_ALPINE_VERSION: ${{ github.event.inputs.IMAGE_ALPINE_VERSION || '3.22' }} @@ -197,6 +184,8 @@ jobs: # runs-on: ubuntu-latest runs-on: apollo-x64 timeout-minutes: 4 + outputs: + package_version: ${{ steps.task_initialize_package_getversion.outputs.PACKAGE_VERSION }} permissions: contents: write packages: write @@ -222,6 +211,26 @@ jobs: uses: qoomon/actions--context@v4 id: 'context' + # # + # Release β€Ί Tags β€Ί Set β€Ί Package.json β€Ί Version + # # + + - name: 'πŸ‘οΈβ€πŸ—¨οΈ Package Version β€Ί Set' + id: task_initialize_package_getversion + working-directory: ./tvapp2 + run: | + VER=$(cat package.json | jq -r '.version') + echo "PACKAGE_VERSION=${VER}" >> $GITHUB_OUTPUT + echo "PACKAGE_VERSION=${VER}" >> $GITHUB_ENV + + # # + # Initialize β€Ί Get β€Ί Package.json β€Ί Version + # # + + - name: 'πŸ‘οΈβ€πŸ—¨οΈ Package Version β€Ί Get' + run: | + echo "VERSION: ${{ steps.task_initialize_package_getversion.outputs.PACKAGE_VERSION }}" + # # # Release β€Ί Tags β€Ί Start # # @@ -258,10 +267,10 @@ jobs: SHA1_GH="$(echo ${GITHUB_SHA})" # 71fad013cfce9116ec62779e4a7e627fe4c33627 echo "SHA1_GH=${SHA1_GH}" >> $GITHUB_ENV - PKG_VER_1DIGIT="$(echo ${{ env.IMAGE_VERSION }} | cut -d '.' -f1-1)" # 3.22 > 3 + PKG_VER_1DIGIT="$(echo ${{ env.PACKAGE_VERSION }} | cut -d '.' -f1-1)" # 3.22 > 3 echo "PKG_VER_1DIGIT=${PKG_VER_1DIGIT}" >> $GITHUB_ENV - PKG_VER_2DIGIT="$(echo ${{ env.IMAGE_VERSION }} | cut -f2 -d ":" | cut -c1-3)" # 3.22 > 3.2 + PKG_VER_2DIGIT="$(echo ${{ env.PACKAGE_VERSION }} | cut -f2 -d ":" | cut -c1-3)" # 3.22 > 3.2 echo "PKG_VER_2DIGIT=${PKG_VER_2DIGIT}" >> $GITHUB_ENV echo "―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――" @@ -323,7 +332,7 @@ jobs: echo "β€Ž" # # - # Tags β€Ί Tags β€Ί Fix Permissions + # Release β€Ί Tags β€Ί Fix Permissions # # - name: '#️⃣ Manage Permissions' @@ -349,9 +358,9 @@ jobs: - uses: rickstaa/action-create-tag@v1 if: ( github.event_name != 'workflow_dispatch' && inputs.DRY_RUN == false ) with: - tag: "${{ env.IMAGE_VERSION }}" + tag: "${{ env.PACKAGE_VERSION }}" tag_exists_error: false - message: '${{ env.IMAGE_NAME }}-${{ env.IMAGE_VERSION }}' + message: '${{ env.IMAGE_NAME }}-${{ env.PACKAGE_VERSION }}' gpg_private_key: ${{ secrets.ADMINSERV_GPG_KEY_ASC }} gpg_passphrase: ${{ secrets.ADMINSERV_GPG_PASSPHRASE }} @@ -365,12 +374,14 @@ jobs: # runs-on: ubuntu-latest runs-on: apollo-x64 timeout-minutes: 10 + needs: [ job-docker-release-tags-create ] permissions: contents: write packages: write attestations: write id-token: write - needs: [ job-docker-release-tags-create ] + env: + PACKAGE_VERSION: ${{ needs.job-docker-release-tags-create.outputs.package_version }} steps: # # @@ -427,10 +438,10 @@ jobs: SHA1_GH="$(echo ${GITHUB_SHA})" # 71fad013cfce9116ec62779e4a7e627fe4c33627 echo "SHA1_GH=${SHA1_GH}" >> $GITHUB_ENV - PKG_VER_1DIGIT="$(echo ${{ env.IMAGE_VERSION }} | cut -d '.' -f1-1)" # 3.22 > 3 + PKG_VER_1DIGIT="$(echo ${{ env.PACKAGE_VERSION }} | cut -d '.' -f1-1)" # 3.22 > 3 echo "PKG_VER_1DIGIT=${PKG_VER_1DIGIT}" >> $GITHUB_ENV - PKG_VER_2DIGIT="$(echo ${{ env.IMAGE_VERSION }} | cut -f2 -d ":" | cut -c1-3)" # 3.22 > 3.2 + PKG_VER_2DIGIT="$(echo ${{ env.PACKAGE_VERSION }} | cut -f2 -d ":" | cut -c1-3)" # 3.22 > 3.2 echo "PKG_VER_2DIGIT=${PKG_VER_2DIGIT}" >> $GITHUB_ENV echo "―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――" @@ -611,7 +622,7 @@ jobs: type=ref,enable=${{ github.event_name == 'pull_request' || github.event_name == 'push' }},priority=600,prefix=,suffix=,event=tag # tag add 1.0.0 ( dispatch only + no dev ) - type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == false }},priority=450,prefix=,suffix=,value=${{ env.IMAGE_VERSION }} + type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == false }},priority=450,prefix=,suffix=,value=${{ env.PACKAGE_VERSION }} # tag add 1.0 ( dispatch only + no dev ) type=raw,enable=${{ github.event_name == 'workflow_dispatch' && inputs.DEV_RELEASE == false }},priority=425,prefix=,suffix=,value=${{ env.PKG_VER_2DIGIT }} @@ -629,28 +640,28 @@ jobs: labels: | org.opencontainers.image.description=TVApp2 org.opencontainers.image.created=${{ env.NOW_DOCKER_TS }} - org.opencontainers.image.version=${{ env.IMAGE_VERSION }} + org.opencontainers.image.version=${{ env.PACKAGE_VERSION }} org.opencontainers.image.licenses=MIT org.opencontainers.image.revision=${{ env.SHA1 }} org.opencontainers.image.vendor=${{ env.REGISTRY_REPO_AUTHOR_LC }} org.opencontainers.image.ref.name=${{ github.ref_name }} org.opencontainers.image.development=${{ inputs.DEV_RELEASE == true && 'true' || 'false' }} org.opencontainers.image.registry=${{ env.IMAGE_REGISTRY }} - org.tvapp2.image.build-version="Version:- ${{ env.IMAGE_VERSION }} Date:- ${{ env.NOW_DOCKER }}" + org.tvapp2.image.build-version="Version: ${{ env.PACKAGE_VERSION }} Date: ${{ env.NOW_DOCKER }}" org.tvapp2.image.build-version-alpine=${{ env.IMAGE_ALPINE_VERSION }} org.tvapp2.image.build-release="${{ inputs.DEV_RELEASE == true && 'development' || 'stable' }}" org.tvapp2.image.build-sha1=${{ env.SHA1 }} annotations: |- org.opencontainers.image.description=TVApp2 org.opencontainers.image.created=${{ env.NOW_DOCKER_TS }} - org.opencontainers.image.version=${{ env.IMAGE_VERSION }} + org.opencontainers.image.version=${{ env.PACKAGE_VERSION }} org.opencontainers.image.licenses=MIT org.opencontainers.image.revision=${{ env.SHA1 }} org.opencontainers.image.vendor=${{ env.REGISTRY_REPO_AUTHOR_LC }} org.opencontainers.image.ref.name=${{ github.ref_name }} org.opencontainers.image.development=${{ inputs.DEV_RELEASE == true && 'true' || 'false' }} org.opencontainers.image.registry=${{ env.IMAGE_REGISTRY }} - org.tvapp2.image.build-version="Version:- ${{ env.IMAGE_VERSION }} Date:- ${{ env.NOW_DOCKER }}" + org.tvapp2.image.build-version="Version: ${{ env.PACKAGE_VERSION }} Date: ${{ env.NOW_DOCKER }}" org.tvapp2.image.build-version-alpine=${{ env.IMAGE_ALPINE_VERSION }} org.tvapp2.image.build-release="${{ inputs.DEV_RELEASE == true && 'development' || 'stable' }}" org.tvapp2.image.build-sha1=${{ env.SHA1 }} @@ -679,14 +690,14 @@ jobs: build-args: |- ARCH=amd64 RELEASE=${{ inputs.DEV_RELEASE == true && 'development' || 'stable' }} - VERSION=${{ env.IMAGE_VERSION }} + VERSION=${{ env.PACKAGE_VERSION }} BUILDDATE=${{ env.NOW_DOCKER }} GIT_SHA1=${{ env.SHA1 }} ALPINE_VERSION=${{ env.IMAGE_ALPINE_VERSION }} annotations: |- org.opencontainers.image.description=TVApp2 org.opencontainers.image.created=${{ env.NOW_DOCKER_TS }} - org.opencontainers.image.version=${{ env.IMAGE_VERSION }} + org.opencontainers.image.version=${{ env.PACKAGE_VERSION }} org.opencontainers.image.licenses=MIT org.opencontainers.image.architecture=amd64 org.opencontainers.image.revision=${{ env.SHA1 }} @@ -694,7 +705,7 @@ jobs: org.opencontainers.image.ref.name=${{ github.ref_name }} org.opencontainers.image.development=${{ inputs.DEV_RELEASE == true && 'true' || 'false' }} org.opencontainers.image.registry=${{ env.IMAGE_REGISTRY }} - org.tvapp2.image.build-version="Version:- ${{ env.IMAGE_VERSION }} Date:- ${{ env.NOW_DOCKER }}" + org.tvapp2.image.build-version="Version: ${{ env.PACKAGE_VERSION }} Date: ${{ env.NOW_DOCKER }}" org.tvapp2.image.build-version-alpine=${{ env.IMAGE_ALPINE_VERSION }} org.tvapp2.image.build-architecture=amd64 org.tvapp2.image.build-release="${{ inputs.DEV_RELEASE == true && 'development' || 'stable' }}" @@ -750,14 +761,14 @@ jobs: build-args: |- ARCH=arm64 RELEASE=${{ inputs.DEV_RELEASE == true && 'development' || 'stable' }} - VERSION=${{ env.IMAGE_VERSION }} + VERSION=${{ env.PACKAGE_VERSION }} BUILDDATE=${{ env.NOW_DOCKER }} GIT_SHA1=${{ env.SHA1 }} ALPINE_VERSION=${{ env.IMAGE_ALPINE_VERSION }} annotations: |- org.opencontainers.image.description=TVApp2 org.opencontainers.image.created=${{ env.NOW_DOCKER_TS }} - org.opencontainers.image.version=${{ env.IMAGE_VERSION }} + org.opencontainers.image.version=${{ env.PACKAGE_VERSION }} org.opencontainers.image.licenses=MIT org.opencontainers.image.architecture=arm64 org.opencontainers.image.revision=${{ env.SHA1 }} @@ -765,7 +776,7 @@ jobs: org.opencontainers.image.ref.name=${{ github.ref_name }} org.opencontainers.image.development=${{ inputs.DEV_RELEASE == true && 'true' || 'false' }} org.opencontainers.image.registry=${{ env.IMAGE_REGISTRY }} - org.tvapp2.image.build-version="Version:- ${{ env.IMAGE_VERSION }} Date:- ${{ env.NOW_DOCKER }}" + org.tvapp2.image.build-version="Version: ${{ env.PACKAGE_VERSION }} Date: ${{ env.NOW_DOCKER }}" org.tvapp2.image.build-version-alpine=${{ env.IMAGE_ALPINE_VERSION }} org.tvapp2.image.build-architecture=arm64 org.tvapp2.image.build-release="${{ inputs.DEV_RELEASE == true && 'development' || 'stable' }}" @@ -815,7 +826,6 @@ jobs: echo "β€Ž" echo "---- [ INPUTS ] ----------------------------------------------------------------------------------------" echo "inputs.IMAGE_NAME ........................ ${{ inputs.IMAGE_NAME }}" - echo "inputs.IMAGE_VERSION ..................... ${{ inputs.IMAGE_VERSION }}" echo "inputs.IMAGE_GHCR_AUTHOR ................. ${{ inputs.IMAGE_GHCR_AUTHOR }}" echo "inputs.IMAGE_GHCR_USERNAME ............... ${{ inputs.IMAGE_GHCR_USERNAME }}" echo "inputs.DEV_RELEASE ....................... ${{ inputs.DEV_RELEASE }}" @@ -823,7 +833,7 @@ jobs: echo "β€Ž" echo "---- [ ENV ] -------------------------------------------------------------------------------------------" echo "env.IMAGE_NAME ........................... ${{ env.IMAGE_NAME }}" - echo "env.IMAGE_VERSION ........................ ${{ env.IMAGE_VERSION }}" + echo "env.PACKAGE_VERSION ...................... ${{ env.PACKAGE_VERSION }}" echo "env.PKG_VER_1DIGIT ....................... ${{ env.PKG_VER_1DIGIT }}" echo "env.PKG_VER_2DIGIT ....................... ${{ env.PKG_VER_2DIGIT }}" echo "env.IMAGE_GHCR_AUTHOR .................... ${{ env.IMAGE_GHCR_AUTHOR }}" @@ -897,20 +907,20 @@ jobs: embed-url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" embed-thumbnail-url: ${{ env.DISCORD_BOT_EMBED_THUMBNAIL }} embed-description: | - ### πŸ“¦ α²ΌDeploy (Github) α²Ό${{ job.status == 'success' && 'βœ…' || '❌' }}α²Ό β€Ί `${{ env.IMAGE_NAME }}-${{ env.IMAGE_VERSION }}${{ inputs.DEV_RELEASE == true && '-development' || '' }}` + ### πŸ“¦ α²ΌDeploy (Github) α²Ό${{ job.status == 'success' && 'βœ…' || '❌' }}α²Ό β€Ί `${{ env.IMAGE_NAME }}-${{ env.PACKAGE_VERSION }}${{ inputs.DEV_RELEASE == true && '-development' || '' }}` ${{ inputs.DEV_RELEASE == true && '### ⚠️⚠️ Development / Pre-release ⚠️⚠️' || '' }} A new version of the docker container `${{ env.IMAGE_NAME }}` has been released from Github to Github GHCR. The image is available at: - https://github.com/${{ github.repository }}/pkgs/container/${{ env.IMAGE_NAME }} - - Version: `${{ env.IMAGE_VERSION }}` + - Version: `${{ env.PACKAGE_VERSION }}` - Release Type: `${{ inputs.DEV_RELEASE == true && '⚠️⚠️ Development / Pre-release ⚠️⚠️' || 'Stable' }}` - - Pull: `docker pull ghcr.io/${{ env.REGISTRY_REPO_ORG_AUTHOR_LC }}:${{ inputs.DEV_RELEASE == true && 'development' || env.IMAGE_VERSION }}` + - Pull: `docker pull ghcr.io/${{ env.REGISTRY_REPO_ORG_AUTHOR_LC }}:${{ inputs.DEV_RELEASE == true && 'development' || env.PACKAGE_VERSION }}` - Pull (amd64): `docker pull ghcr.io/${{ env.REGISTRY_REPO_ORG_AUTHOR_LC }}@${{ steps.task_release_gh_push_amd64.outputs.digest }}` - Pull (arm64): `docker pull ghcr.io/${{ env.REGISTRY_REPO_ORG_AUTHOR_LC }}@${{ steps.task_release_gh_push_arm64.outputs.digest }}` - Dry Run: `${{ inputs.DRY_RUN }}` - Source: `Github` https://github.com/${{ github.repository }} - - Docker Image: `${{ env.IMAGE_NAME }}-${{ env.IMAGE_VERSION }}${{ inputs.DEV_RELEASE == true && '-development' || '' }}` + - Docker Image: `${{ env.IMAGE_NAME }}-${{ env.PACKAGE_VERSION }}${{ inputs.DEV_RELEASE == true && '-development' || '' }}` - Branch: `${{ github.ref_name }}` - Workflow: `${{ github.workflow }} (#${{github.run_number}})` - Runner: `${{ runner.name }}` @@ -947,12 +957,14 @@ jobs: # runs-on: ubuntu-latest runs-on: apollo-x64 timeout-minutes: 5 + needs: [ job-docker-release-tags-create, job-docker-release-github ] permissions: contents: write packages: write attestations: write id-token: write - needs: [ job-docker-release-tags-create, job-docker-release-github ] + env: + PACKAGE_VERSION: ${{ needs.job-docker-release-tags-create.outputs.package_version }} steps: # # @@ -964,6 +976,14 @@ jobs: with: fetch-depth: 0 + # # + # Release β€Ί Cleanup β€Ί Print Version Debug + # # + + - name: 'πŸͺͺ Get Package Version' + run: | + echo "VERSION: ${{ env.PACKAGE_VERSION }}" + # # # Release β€Ί Cleanup β€Ί Clean Untagged Images # #