-
Notifications
You must be signed in to change notification settings - Fork 3
42 lines (36 loc) · 1.04 KB
/
publish.yaml
File metadata and controls
42 lines (36 loc) · 1.04 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
name: Publish
on:
release:
types: [created]
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6.3.0
with:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
cache: 'yarn'
- name: install
run: yarn install
- name: Update package.json version to match tag
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/}"
# Remove leading 'v' if present in tag
if [[ "$TAG_VERSION" == v* ]]; then
TAG_VERSION="${TAG_VERSION:1}"
fi
node -e "
const fs = require('fs');
const pkg = require('./package.json');
pkg.version = process.env.TAG_VERSION;
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
"
env:
TAG_VERSION: ${{ github.ref_name }}
- name: publish
run: npm publish