Skip to content

Commit 644b0ab

Browse files
committed
fix: prepare release automation
1 parent b674455 commit 644b0ab

File tree

4 files changed

+7524
-1376
lines changed

4 files changed

+7524
-1376
lines changed

Diff for: .github/workflows/ci.yml

+39
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
name: CI
22

3+
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
4+
run-name: >-
5+
${{
6+
inputs.release && 'CI ➤ Publish to NPM' ||
7+
''
8+
}}
9+
310
on:
411
pull_request:
512
push:
613
branches: [main]
14+
workflow_dispatch:
15+
inputs:
16+
release:
17+
description: 'Publish new release'
18+
required: true
19+
default: false
20+
type: boolean
721

822
concurrency:
923
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -20,3 +34,28 @@ jobs:
2034
cache: npm
2135
- run: npm ci
2236
- run: npm test
37+
38+
release:
39+
needs: [test]
40+
# only run if opt-in during workflow_dispatch
41+
if: always() && github.event.inputs.release == 'true'
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v3
45+
with:
46+
# Need to fetch entire commit history to
47+
# analyze every commit since last release
48+
fetch-depth: 0
49+
- uses: actions/setup-node@v3
50+
with:
51+
node-version: lts/*
52+
cache: npm
53+
- run: npm ci
54+
# Branches that will release new versions are defined in .releaserc.json
55+
- run: npx semantic-release
56+
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
57+
# e.g. git tags were pushed but it exited before `npm publish`
58+
if: always()
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

Diff for: .releaserc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@sanity/semantic-release-preset",
3+
"branches": ["main"]
4+
}

0 commit comments

Comments
 (0)