Skip to content

Commit bee85d4

Browse files
authoredNov 14, 2023
ci: add easy way to create pre releases (#65)
1 parent ec7c681 commit bee85d4

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
 

‎.github/workflows/pre-release.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: prerelease
2+
on:
3+
push:
4+
branches:
5+
# releases/<tag>/<version>
6+
# releases/alpha.1/5.0.0 - will result in 5.0.0-alpha.1
7+
- releases/*/*
8+
jobs:
9+
prerelease:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v3
17+
with:
18+
node-version: lts/*
19+
cache: npm
20+
registry-url: 'https://registry.npmjs.org'
21+
- name: Install core dependencies
22+
run: npm ci --no-audit
23+
- name: Extract tag and version
24+
id: extract
25+
run: |-
26+
ref=${{ github.ref }}
27+
branch=${ref:11}
28+
tag_version=${branch:9}
29+
tag=${tag_version%/*}
30+
version=${tag_version##*/}
31+
echo "tag=${tag}" >> $GITHUB_OUTPUT
32+
echo "version=${version}" >> $GITHUB_OUTPUT
33+
- name: Log versions
34+
run: |-
35+
echo tag=${{ steps.extract.outputs.tag }}
36+
echo version=${{ steps.extract.outputs.version }}
37+
- name: Setup git user
38+
run: git config --global user.name github-actions
39+
- name: Setup git email
40+
run: git config --global user.email github-actions@github.com
41+
- name: Run npm version
42+
run:
43+
npm version ${{ steps.extract.outputs.version }}-${{ steps.extract.outputs.tag }}
44+
--allow-same-version
45+
- name: Push changes
46+
run: git push --follow-tags
47+
- name: Run npm publish
48+
run: npm publish --tag=${{ steps.extract.outputs.tag }}
49+
env:
50+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

0 commit comments

Comments
 (0)