diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index f3e131ac32..6aba908287 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -5,6 +5,11 @@ on: types: - published workflow_dispatch: + inputs: + tag: + description: 'Release tag to process (optional)' + required: false + default: '' env: NODE_VERSION: 22.6.0 @@ -13,14 +18,28 @@ env: NEXT_TELEMETRY_DISABLED: 1 # Disable Next telemetry jobs: + determine_tag: + runs-on: ubuntu-latest + outputs: + release_tag: ${{ steps.determine.outputs.release_tag }} + steps: + - name: Determine Release Tag + id: determine + run: | + if [ "${{ github.event.inputs.tag }}" != "" ]; then + echo "Using tag from input: ${{ github.event.inputs.tag }}" + echo "release_tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + else + echo "Using tag from release event: ${{ github.event.release.tag_name }}" + echo "release_tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT + fi + post_release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - # Only needed if debugging on a branch other than default - # ref: ${{ github.event.release.target_commitish || github.ref }} - uses: ./.github/actions/release-commenter continue-on-error: true env: @@ -35,11 +54,10 @@ jobs: comment-template: | 🚀 This is included in version {release_link} - # Some templates have lockfiles that must point to the new release - # This runs the necessary script and creates a PR with the changes update_templates: + needs: determine_tag runs-on: ubuntu-latest - if: startsWith(github.event.release.tag_name, 'v3') + if: startsWith(needs.determine_tag.outputs.release_tag, 'v3') permissions: contents: write pull-requests: write @@ -63,18 +81,15 @@ jobs: set -ex git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - export RELEASE_TAG=$(echo ${{ github.event.release.tag_name }}) - export BRANCH_NAME=chore/templates-$RELEASE_TAG + export BRANCH_NAME=chore/templates-${{ needs.determine_tag.outputs.release_tag }} git checkout -b $BRANCH_NAME git add -A # If no files have changed, exit early with success git diff --cached --quiet --exit-code && exit 0 - git commit -m "chore(templates): bump lockfiles after $RELEASE_TAG" + git commit -m "chore(templates): bump lockfiles after ${{ needs.determine_tag.outputs.release_tag }}" git push origin $BRANCH_NAME - # export the tag for use in the next job - echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV echo "committed=true" >> "$GITHUB_OUTPUT" - name: Create pull request @@ -85,7 +100,7 @@ jobs: labels: 'area: templates' author: github-actions[bot] commit-message: 'Automated update after release' - branch: chore/templates-$RELEASE_TAG + branch: chore/templates-${{ needs.determine_tag.outputs.release_tag }} base: ${{ github.event.release.target_commitish }} - title: 'chore(templates): bump lockfiles after $RELEASE_TAG' - body: 'Automated bump of template lockfiles after release $RELEASE_TAG' + title: 'chore(templates): bump lockfiles after ${{ needs.determine_tag.outputs.release_tag }}' + body: 'Automated bump of template lockfiles after release ${{ needs.determine_tag.outputs.release_tag }}'