From 12114df52eacdac15a37af8aef41e30b56930d63 Mon Sep 17 00:00:00 2001 From: francesco-racciatti Date: Fri, 19 Apr 2024 17:55:37 +0200 Subject: [PATCH] build(promote): add promote action This action promotes the target RC tag and creates a release (marked as latest) based on it. Signed-off-by: francesco-racciatti --- .github/workflows/promote.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/promote.yml diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml new file mode 100644 index 0000000..b9cd4a9 --- /dev/null +++ b/.github/workflows/promote.yml @@ -0,0 +1,72 @@ +name: promote + +on: + workflow_dispatch: + inputs: + release_version: + description: 'The release version, e.g. 5.0.0.' + type: string + required: true + + rc_number: + description: 'The release candidate number to promote, e.g. 1.' + type: string + required: true + +jobs: + promote: + env: + RC_NAME: ${{ inputs.release_version }}-rc${{ inputs.rc_tag }} + name: Promote + runs-on: ubuntu-latest + steps: + - name: Verify inputs + shell: bash + run: | + if [[ ! "${{ inputs.release_version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + echo "The provided release version is not valid" + exit 1 + fi + + if [[ ! "${{ inputs.rc_number }}" =~ ^([0-9])+$ ]]; then + echo "The provided rc tag is not valid" + exit 1 + fi + + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Promote RC Tag + shell: bash + run: | + if ! git rev-parse "${RC_NAME}" &>/dev/null; then + echo "The RC Tag ${RC_NAME} does not exist" + exit 1 + fi + + git fetch --tags + git tag "${{ inputs.release_version }}" "${RC_NAME}" + git push -u origin "${{ inputs.release_version }}" + + - name: Get resources from RC + shell: bash + run: | + rm -f cloudformation.zip + rm -f checksums.txt + curl -L "https://github.com/${{ github.repository }}/releases/download/${RC_NAME}/cloudformation.zip" > cloudformation.zip + curl -L "https://github.com/${{ github.repository }}/releases/download/${RC_NAME}/checksums.txt" > checksums.txt + + - name: Create release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + cloudformation.zip + checksums.txt + name: ${{ inputs.release_version }} + tag_name: ${{ inputs.release_version }} + prerelease: false + make_latest: true