-
Notifications
You must be signed in to change notification settings - Fork 206
55 lines (53 loc) · 1.82 KB
/
release-snapshot.yml
File metadata and controls
55 lines (53 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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@v5
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: 20.20.0
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