chore(release): merge release/4.0.3 into main #17
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish new github release | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
jobs: | |
release: | |
name: Publish new release | |
runs-on: ubuntu-latest | |
if: (startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true # only merged pull requests must trigger this job | |
steps: | |
- name: Extract version from branch name (for release branches) | |
id: extract-version | |
run: | | |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
VERSION=${BRANCH_NAME#hotfix-} | |
VERSION=${VERSION#release/} | |
echo "release_version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'npm' | |
# In order to make a commit, we need to initialize a user. | |
# You may choose to write something less generic here if you want, it doesn't matter functionality wise. | |
- name: Initialize mandatory git config | |
run: | | |
git config user.name "GitHub actions" | |
git config user.email [email protected] | |
- name: Create GitHub Release | |
id: create_release | |
env: | |
HUSKY: 0 | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git tag -a v${{ steps.extract-version.outputs.release_version }} -m "chore: release v${{ steps.extract-version.outputs.release_version }}" | |
git push origin refs/tags/v${{ steps.extract-version.outputs.release_version }} | |
npx conventional-github-releaser -p angular | |
echo "DATE=$(date)" >> $GITHUB_ENV | |
- name: Create pull request into develop | |
if: always() | |
continue-on-error: true | |
env: | |
GH_TOKEN: ${{ secrets.PAT }} | |
run: | | |
pr_title="chore(release): merge main into develop after release v${{ steps.extract-version.outputs.release_version }}" | |
# Create PR body with proper formatting | |
cat > pr_body.md << EOF | |
:crown: **Automated Post-Release PR** | |
This pull request was created automatically by the GitHub Actions workflow. It merges changes from the \`main\` branch into the \`develop\` branch after a release has been completed. | |
This ensures that the \`develop\` branch stays up to date with all release-related changes from the \`main\` branch. | |
### Details | |
- **Release Version**: v${{ steps.extract-version.outputs.release_version }} | |
--- | |
Please review and merge it before closing the release ticket. :rocket: | |
EOF | |
# Create the PR using GitHub CLI | |
gh pr create \ | |
--base develop \ | |
--head main \ | |
--title "$pr_title" \ | |
--body-file pr_body.md | |
- name: Send message to Slack channel | |
id: slack | |
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0 | |
env: | |
PROJECT_NAME: 'Gatsby Plugin' | |
RELEASES_URL: 'https://github.com/rudderlabs/gatsby-plugin-rudderstack/releases/' | |
with: | |
method: 'chat.postMessage' | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
retries: rapid | |
payload-templated: true | |
payload: | | |
{ | |
"channel": ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}, | |
"text": "*New Release: ${{ env.PROJECT_NAME }} - <${{env.RELEASES_URL}}${{ steps.extract-version.outputs.release_version }}|v${{ steps.extract-version.outputs.release_version }}>*\n${{ env.DATE }}\nCC: <!subteam^S0555JBV36D> <!subteam^S03SHJ20350>", | |
"blocks": [ | |
{ | |
"type": "header", | |
"text": { | |
"type": "plain_text", | |
"text": "New Release: ${{ env.PROJECT_NAME }}" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*<${{env.RELEASES_URL}}${{ steps.extract-version.outputs.release_version }}|v${{ steps.extract-version.outputs.release_version }}>*\n${{ env.DATE }}\nCC: <!subteam^S0555JBV36D> <!subteam^S03SHJ20350>" | |
}, | |
"accessory": { | |
"type": "image", | |
"image_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", | |
"alt_text": "GitHub Icon" | |
} | |
} | |
] | |
} |