Skip to content

Commit 6463a52

Browse files
committed
Add GitHub Actions workflow for release and publish automation
1 parent 88460ad commit 6463a52

File tree

4 files changed

+487
-6
lines changed

4 files changed

+487
-6
lines changed

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*.*.*"
9+
10+
jobs:
11+
build-and-publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Enable Corepack
18+
run: corepack enable
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
cache: "yarn"
24+
cache-dependency-path: "yarn.lock"
25+
node-version-file: ".nvmrc"
26+
27+
- name: Install dependencies
28+
run: yarn install
29+
30+
- name: Run Biome
31+
run: npx biome ci .
32+
33+
- name: Run tests
34+
run: yarn test
35+
36+
- name: Typecheck
37+
run: yarn typecheck
38+
39+
- name: Set dev version for main branch
40+
if: github.ref == 'refs/heads/main'
41+
run: |
42+
BUILD_NUM=${{ github.run_number }}
43+
COMMIT_HASH=${{ github.sha }}
44+
VERSION=$(jq -r .version package.json)
45+
DEV_VERSION="$VERSION-dev.$BUILD_NUM+${COMMIT_HASH:0:8}"
46+
jq --arg v "$DEV_VERSION" '.version = $v' package.json > package.json.tmp
47+
mv package.json.tmp package.json
48+
49+
- name: Pack npm package
50+
run: mkdir -p out && yarn pack --out out/%s-%v.tgz
51+
52+
- name: Check Package Entrypoints
53+
run: yarn attw out/*.tgz
54+
55+
- name: Publish to registry
56+
if: |
57+
github.event_name == 'push' &&
58+
(github.ref_type == 'tag' || github.ref == 'refs/heads/main')
59+
run: |
60+
set -ex
61+
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
62+
npm whoami
63+
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
64+
npm publish --provenance --access public *.tgz
65+
else
66+
npm publish --provenance --access public --tag dev *.tgz
67+
fi
68+
env:
69+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
working-directory: ${{ github.workspace }}/out/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"jscodeshift": "^17.3.0"
3838
},
3939
"devDependencies": {
40+
"@arethetypeswrong/cli": "^0.18.2",
4041
"@biomejs/biome": "1.9.4",
4142
"@types/jscodeshift": "^17.3.0",
4243
"@types/node": "^22.7.4",

0 commit comments

Comments
 (0)