From db70628a2f3a437810ba96533bc410fa1c2a16ae Mon Sep 17 00:00:00 2001 From: Katherine Chen Date: Mon, 12 Feb 2024 15:55:47 +1100 Subject: [PATCH] UID2-2674 Implement shared publish to docker versioned (#59) * Fix version_number_input for `Create Release` * Fix Docker Release name * Use kcc-UID2-2674-implement-shared-publish-to-docker-versioned for creating release * use the alternative sort approach for retrieving the previous tag * Use v4 version of mikepenz/release-changelog-builder-action * Add v to the release name for the verion number * Use `steps.setup.outputs.is_release` instead of `IS_RELEASE` * Use v2 instead of kcc custom branch * Remove `version_number_input` from inputs * Change `version_number_input` to `new_version` * Remove duplicated `new_version` inputs --- .../shared-increase-version-number.yaml | 4 ++-- .../shared-publish-to-docker-versioned.yaml | 6 +----- actions/shared_create_releases/action.yaml | 21 ++++++++----------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/shared-increase-version-number.yaml b/.github/workflows/shared-increase-version-number.yaml index d2434d1b..18a944b5 100644 --- a/.github/workflows/shared-increase-version-number.yaml +++ b/.github/workflows/shared-increase-version-number.yaml @@ -54,14 +54,14 @@ jobs: echo "image_tag=${{ steps.version.outputs.new_version }}" >> $GITHUB_OUTPUT - name: Commit ${{ inputs.working_dir }}/package.json and ${{ inputs.working_dir }}/version.json - if: ${{ inputs.version_number_input == '' && steps.checkRelease.outputs.IS_RELEASE != 'true' }} + if: ${{ inputs.version_number_input == '' && steps.setup.outputs.is_release != 'true' }} uses: IABTechLab/uid2-shared-actions/actions/commit_pr_and_merge@main with: add: '${{ inputs.working_dir }}/package.json ${{ inputs.working_dir }}/version.json' message: 'Released ${{ inputs.release_type }} version: ${{ steps.version.outputs.new_version }}' - name: Commit ${{ inputs.working_dir }}/package.json, ${{ inputs.working_dir }}/version.json and set tag - if: ${{ inputs.version_number_input == '' && steps.checkRelease.outputs.IS_RELEASE == 'true' }} + if: ${{ inputs.version_number_input == '' && steps.setup.outputs.is_release == 'true' }} uses: IABTechLab/uid2-shared-actions/actions/commit_pr_and_merge@main with: add: '${{ inputs.working_dir }}/package.json ${{ inputs.working_dir }}/version.json' diff --git a/.github/workflows/shared-publish-to-docker-versioned.yaml b/.github/workflows/shared-publish-to-docker-versioned.yaml index 7a8b1d5d..6b02291c 100644 --- a/.github/workflows/shared-publish-to-docker-versioned.yaml +++ b/.github/workflows/shared-publish-to-docker-versioned.yaml @@ -18,10 +18,6 @@ on: description: If true, will attempt to publish any vulnerabilities to GitHub. Defaults to true. Set to false for private repos. type: string default: true - version_number_input: - description: The version number to publish for the docker repo - type: string - default: '' force_release: description: If 'yes', will force the creation a release, if 'no' will not create a release. 'branch' will use release_type and the branch to determine if a release should be created. type: string @@ -77,7 +73,7 @@ jobs: uses: IABTechLab/uid2-shared-actions/actions/shared_create_releases@v2 with: is_release: ${{ steps.setup.outputs.is_release }} - version_number_input: ${{ inputs.version_number_input }} + new_version: ${{ inputs.new_version }} tags: ${{ steps.publishToDocker.outputs.tags }} image_tag: ${{ steps.updatePackageJson.outputs.image_tag }} github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/actions/shared_create_releases/action.yaml b/actions/shared_create_releases/action.yaml index b9fa7fcc..2f3af5b4 100644 --- a/actions/shared_create_releases/action.yaml +++ b/actions/shared_create_releases/action.yaml @@ -5,9 +5,9 @@ inputs: is_release: description: True if a release should be created default: false - version_number_input: - description: If set, the version number will not be incremented and the given number will be used. - default: '' + new_version: + description: The new version number to be incremented to + required: true tags: description: The docker image tags default: '' @@ -23,9 +23,6 @@ inputs: repo: description: The repo that publishing to. default: '' - new_version: - description: The new version that are publish to Maven - default: '' runs: using: "composite" @@ -34,9 +31,9 @@ runs: - name: Build Docker Changelog id: github_release_docker if: ${{ inputs.is_release == 'true' && inputs.publish_platform == 'Docker'}} - uses: mikepenz/release-changelog-builder-action@v3 + uses: mikepenz/release-changelog-builder-action@v4 with: - toTag: v${{ inputs.version_number_input }} + toTag: v${{ inputs.new_version }} configurationJson: | { "template": "#{{CHANGELOG}}\n## Installation\n```\ndocker pull ${{ inputs.tags }}\n```\n\n## Image reference to deploy: \n```\n${{ inputs.image_tag }}\n```\n\n## Changelog\n#{{UNCATEGORIZED}}", @@ -50,7 +47,7 @@ runs: if: ${{ inputs.is_release == 'true' && inputs.publish_platform == 'Maven'}} uses: mikepenz/release-changelog-builder-action@v3 with: - toTag: v${{ inputs.version_number_input }} + toTag: v${{ inputs.new_version }} configurationJson: | { "template": "#{{CHANGELOG}}\n## Maven\n```\n\n com.uid2\n ${{ inputs.repo }}\n ${{ inputs.new_version }}\n\n```\n\n## Jar Files\n- [${{ inputs.repo }}-${{ inputs.new_version }}.jar](https://repo1.maven.org/maven2/com/uid2/${{ inputs.repo }}/${{ inputs.new_version }}/${{ inputs.repo }}-${{ inputs.new_version }}.jar)\n\n## Changelog\n#{{UNCATEGORIZED}}", @@ -60,10 +57,10 @@ runs: GITHUB_TOKEN: ${{ inputs.github_token }} - name: Create Docker Release - if: ${{ inputs.is_release == 'true' }} + if: ${{ inputs.is_release == 'true' && inputs.publish_platform == 'Docker' }} uses: softprops/action-gh-release@v1 with: - name: ${{ inputs.is_release == 'true' && inputs.publish_platform == 'Docker'}} + name: v${{ inputs.new_version }} body: ${{ steps.github_release_docker.outputs.changelog }} draft: true @@ -71,6 +68,6 @@ runs: if: ${{ inputs.is_release == 'true' && inputs.publish_platform == 'Maven'}} uses: softprops/action-gh-release@v1 with: - name: ${{ inputs.version_number_input }} + name: v${{ inputs.new_version }} body: ${{ steps.github_release_maven.outputs.changelog }} draft: true