Skip to content
Merged
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Manual Release

on:
workflow_dispatch:
inputs:
release_version:
description: 'Semver version to release (must be > current root version)'
required: true

permissions:
contents: write
pull-requests: write
id-token: write
packages: write

jobs:
release:
environment: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Validate release version > current
env:
INPUT_VERSION: ${{ inputs.release_version }}
run: |
node -e "
const fs=require('fs');
const semver=require('semver');
const current=JSON.parse(fs.readFileSync('package.json','utf8')).version;
const next=process.env.INPUT_VERSION;
if(!semver.valid(next)) { console.error('Invalid semver: '+next); process.exit(1); }
if(!semver.gt(next,current)) { console.error(`Version ${next} must be greater than current ${current}`); process.exit(1); }
"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to restrict the release to our specific release branches? eg, summer*, winter*, spring*, master?

Is that something we can do in the GHA UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a condition to release job to only be able to run from specified branches and non-fork repos.


- name: Bump versions and commit
env:
INPUT_VERSION: ${{ inputs.release_version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
BRANCH="$GITHUB_REF_NAME"
node ./scripts/release/version.js "$INPUT_VERSION"
RESOLVED_VERSION=$(node -p "require('./package.json').version")
git commit -am "chore: release $RESOLVED_VERSION"
git push origin HEAD

- name: Build
run: yarn build

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
TAG=$([ "$GITHUB_REF_NAME" = "master" ] && echo latest || echo "$GITHUB_REF_NAME")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we ensure that we only release using winter*/spring*/summer* tags, and we don't accidentally release a tag called rave/github-action-publish?

How do we ensure that only repo maintainers can trigger the workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a conditional for branch validation.

How do we ensure that only repo maintainers can trigger the workflow?

This should help with only lwc-admin members should be able to approve workflow run requests.

yarn nx release publish --yes --registry https://registry.npmjs.org --tag "$TAG"
77 changes: 0 additions & 77 deletions .nucleus.yaml

This file was deleted.