Skip to content

docs: make release on rc/** branches possible (#50) #9

docs: make release on rc/** branches possible (#50)

docs: make release on rc/** branches possible (#50) #9

name: Release Branch Automation

Check failure on line 1 in .github/workflows/release-branch-automation.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release-branch-automation.yml

Invalid workflow file

(Line: 62, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.GPG_KEY_CONTENTS != '', (Line: 158, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.GPG_KEY_CONTENTS != ''
on:
workflow_dispatch:
inputs:
version:
description: 'Release Version (semver ie. 0.24.0):'
type: string
required: true
jobs:
branch_bump_tag:
runs-on: hl-contr-lin-lg
env:
RELEASE_NOTES_FILENAME: release_notes
outputs:
create_pr: ${{ env.CREATE_PR }}
next_version_snapshot: ${{ env.NEXT_VERSION_SNAPSHOT }}
pr_title: ${{ env.PR_TITLE }}
release_branch: ${{ env.RELEASE_BRANCH }}
milestone: ${{ env.MILESTONE }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- name: Parse Version
id: version_parser
uses: step-security/semver-utils@4ae9c1fd6d1c5f8f152fe7e2efe8069a952c2ace # v4.3.2
with:
lenient: false
version: ${{ github.event.inputs.version }}
- name: Set Release Environment Variables
run: |
PREMINOR_VERSION=${{ steps.version_parser.outputs.inc-preminor }}
NEXT_VERSION_SNAPSHOT=${PREMINOR_VERSION//-0/-SNAPSHOT}
RELEASE_BRANCH="release/${{ steps.version_parser.outputs.major }}.${{ steps.version_parser.outputs.minor }}"
[[ -z "${{ steps.version_parser.outputs.prerelease }}" ]] && \
VERSION=${{ steps.version_parser.outputs.release }} || \
VERSION="${{ steps.version_parser.outputs.release }}-${{ steps.version_parser.outputs.prerelease }}"
RELEASE_TAG="v${VERSION}"
cat >> $GITHUB_ENV <<EOF
NEXT_VERSION_SNAPSHOT=$NEXT_VERSION_SNAPSHOT
RELEASE_BRANCH=$RELEASE_BRANCH
RELEASE_TAG=$RELEASE_TAG
VERSION=$VERSION
MILESTONE=${{ steps.version_parser.outputs.release}}
EOF
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: main
token: ${{ secrets.GH_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
- name: Import GPG Key
id: gpg_importer
if: ${{ secrets.GPG_KEY_CONTENTS != '' }}
uses: step-security/ghaction-import-gpg@69c854a83c7f79463f8bdf46772ab09826c560cd # v6.3.1
with:
git_commit_gpgsign: true
git_committer_email: ${{ vars.GIT_USER_EMAIL || 'automation@users.noreply.github.com' }}
git_committer_name: ${{ vars.GIT_USER_NAME || 'release-automation' }}
git_tag_gpgsign: true
git_user_signingkey: true
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
- name: Create and Switch to Release Branch
run: |
if ! git ls-remote --exit-code --heads --quiet origin refs/heads/${RELEASE_BRANCH}; then
git checkout -b ${RELEASE_BRANCH}
git push -u origin ${RELEASE_BRANCH}
# create a PR to bump main branch to the next snapshot version
echo "CREATE_PR=true" >> $GITHUB_ENV
echo "PR_TITLE=chore(release): Bump versions for v$NEXT_VERSION_SNAPSHOT" >> $GITHUB_ENV
else
git checkout ${RELEASE_BRANCH}
fi
- name: Use Node.js [24]
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24.12.0
- name: Install dependencies
run: npm ci
- name: Close the Milestone
if: ${{ steps.version_parser.outputs.prerelease == '' }}
id: milestone
uses: step-security/close-milestone@b097272a7aaa0f5c40dc6bc671d45d35c5e85b51 # v2.2.1
with:
milestone_name: ${{ steps.version_parser.outputs.release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release Notes
if: ${{ steps.milestone.outputs.milestone_id != '' }}
uses: step-security/release-notes-generator-action@796ee9c88dd2346ea1a5e9e85ca6cbd1e24e2e6a # v3.2.2
env:
FILENAME: ${{ env.RELEASE_NOTES_FILENAME }}
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
MILESTONE_NUMBER: ${{ steps.milestone.outputs.milestone_id }}
- name: Commit and Tag
uses: step-security/git-auto-commit-action@e2d505468267a3cb406af729d48d664de1f16393 # v6.0.2
with:
commit_author: ${{ steps.gpg_importer.outputs.name || vars.GIT_USER_NAME || 'release-automation' }} <${{ steps.gpg_importer.outputs.email || vars.GIT_USER_EMAIL || 'automation@users.noreply.github.com' }}>
commit_message: 'chore(release): Bump versions for ${{ env.RELEASE_TAG }}'
commit_options: '--no-verify --signoff'
commit_user_name: ${{ steps.gpg_importer.outputs.name || vars.GIT_USER_NAME || 'release-automation' }}
commit_user_email: ${{ steps.gpg_importer.outputs.email || vars.GIT_USER_EMAIL || 'automation@users.noreply.github.com' }}
tagging_message: ${{ env.RELEASE_TAG }}
- name: Create Github Release (draft)
uses: step-security/release-action@03a57407052f15d1537fd5469a6fbbc536aba326 # v1.20.0
with:
bodyFile: ${{ env.RELEASE_NOTES_FILENAME }}.md
commit: ${{ env.RELEASE_BRANCH }}
draft: true
name: ${{ env.RELEASE_TAG }}
omitBody: ${{ steps.milestone.outputs.milestone_id == '' }}
prerelease: ${{ steps.version_parser.outputs.prerelease != '' }}
tag: ${{ env.RELEASE_TAG }}
token: ${{ secrets.GH_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
create_snapshot_pr:
name: Create snapshot PR
runs-on: hl-contr-lin-lg
needs: branch_bump_tag
if: ${{ needs.branch_bump_tag.outputs.create_pr == 'true' }}
env:
NEXT_VERSION_SNAPSHOT: ${{ needs.branch_bump_tag.outputs.next_version_snapshot }}
RELEASE_BRANCH: ${{ needs.branch_bump_tag.outputs.release_branch }}
PR_TITLE: ${{ needs.branch_bump_tag.outputs.pr_title }}
MILE_STONE: ${{ needs.branch_bump_tag.outputs.milestone }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: main
token: ${{ secrets.GH_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
- name: Import GPG Key
id: gpg_importer
if: ${{ secrets.GPG_KEY_CONTENTS != '' }}
uses: step-security/ghaction-import-gpg@69c854a83c7f79463f8bdf46772ab09826c560cd # v6.3.1
with:
git_commit_gpgsign: true
git_tag_gpgsign: true
git_user_signingkey: true
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
- name: Use Node.js [24]
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24.12.0
- name: Install dependencies
run: npm ci
- name: Create Pull Request
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
body: |
**Description**:
Bump versions for v${{ env.NEXT_VERSION_SNAPSHOT }}
Automated snapshot version bump for the next development cycle.
**Related issue(s)**:
branch: create-pull-request/${{ env.NEXT_VERSION_SNAPSHOT }}
commit-message: ${{ env.PR_TITLE }}
committer: ${{ steps.gpg_importer.outputs.name || vars.GIT_USER_NAME || 'release-automation' }} <${{ steps.gpg_importer.outputs.email || vars.GIT_USER_EMAIL || 'automation@users.noreply.github.com' }}>
author: ${{ steps.gpg_importer.outputs.name || vars.GIT_USER_NAME || 'release-automation' }} <${{ steps.gpg_importer.outputs.email || vars.GIT_USER_EMAIL || 'automation@users.noreply.github.com' }}>
delete-branch: true
signoff: true
title: ${{ env.PR_TITLE }}
milestone: ${{ env.MILE_STONE }}
labels: 'process'
token: ${{ secrets.GH_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}