Skip to content

new script for version bumps #10

new script for version bumps

new script for version bumps #10

Workflow file for this run

name: Release and Versioning
on:
push:
branches:
- main
- fix_yarn_version_cli
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write # Highly security sensitive. Do NOT add third party actions in this job
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # Need at least 2 commits to compare versions
- name: Check last PR labels
id: check_labels
env:
GH_TOKEN: ${{ github.token }}
run: |
LAST_PR_NUMBER=$(gh pr list --state merged --json number --jq '.[0].number')
LABELS=$(gh pr view "$LAST_PR_NUMBER" --json labels --jq '.labels[].name')
echo "::notice::PR used to check version bump: #$LAST_PR_NUMBER"
echo "::notice::PR labels: "[${LABELS//$'\n'/,}]""
RELEASE_TYPE=$(./.github/ci-scripts/pr-label-check.sh)
if [ "$RELEASE_TYPE" == "no-release" ]; then
echo "::notice::PR is not flagged for release, skipping other steps"
else
echo "::notice::Release label found: $RELEASE_TYPE"
fi
- name: Bump version
id: bump
if: steps.check_labels.outputs.version != 'no-release'
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
if [ "${{ steps.check_labels.outputs.version }}" == "alpha" ]; then
npm version -m "[bot] New pkg version: %s" --preid=alpha prerelease
else
npm version -m "[bot] New pkg version: %s" ${{ steps.check_labels.outputs.version }}
fi
- name: Create GitHub Release
if: steps.bump.outcome == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(node -p "require('./package.json').version")
gh release create "v${VERSION}" \
--title "Release v${VERSION}" \
--generate-notes \
--prerelease \
--target "${COMMIT_SHA}"