Release Snapshot #24
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
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 | |
- uses: moonrepo/setup-toolchain@v0 | |
with: | |
auto-install: true | |
- run: moon setup | |
- run: moon run :build --query "projectSource~packages/*" | |
- name: Snapshot release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_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: | | |
pnpm changeset version --snapshot $SNAPSHOT_TAG | |
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 | |
pnpm changeset publish --tag $SNAPSHOT_TAG | |
git push origin HEAD | |
git push --tags |