-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add snapshot release workflow (#3071)
* ci: add snapshot release workflow Inspired by @GarthDB and Spectrum Tokens, this adds an on-demand snapshot release workflow. Any user with write access can trigger the workflow to run against a branch and a snapshot release will be published from there based upon the changeset(s) added to the branch's commit history. * docs: provide information for automated & manual snapshot pubs
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Release Snapshot | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: "Tag used on changeset version and npm package" | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
get-snapshot-tag: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
steps: | ||
- name: Split branch name | ||
id: split | ||
env: | ||
BRANCH: ${{ github.ref_name }} | ||
run: echo "fragment=${BRANCH##*snapshot-}" >> $GITHUB_OUTPUT | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get last author info | ||
id: author | ||
run: | | ||
echo "authorName=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT | ||
echo "authorEmail=$(git log -1 --pretty=format:'%ae')" >> $GITHUB_OUTPUT | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
- name: Install Dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Create snapshot release and publish to npm | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
SNAPSHOT_TAG: ${{ inputs.tag || steps.split.outputs.fragment }} | ||
USERNAME: ${{ steps.author.outputs.authorName }} | ||
EMAIL: ${{ steps.author.outputs.authorEmail }} | ||
run: | | ||
yarn changeset version --snapshot $SNAPSHOT_TAG && yarn --mode="update-lockfile" | ||
yarn ci | ||
git config --global user.name "$USERNAME" | ||
git config --global user.email "$EMAIL" | ||
git add . | ||
git commit -m "chore: snapshot release $SNAPSHOT_TAG" | ||
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN | ||
yarn changeset publish --tag $SNAPSHOT_TAG | ||
git push origin HEAD | ||
git push --tags |
This file contains 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