-
Notifications
You must be signed in to change notification settings - Fork 5
108 lines (88 loc) · 2.83 KB
/
release.yml
File metadata and controls
108 lines (88 loc) · 2.83 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Canary & Release
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
jobs:
canary-release:
# Skip if commit message contains [skip ci] or starts with "chore: release"
if: |
!contains(github.event.head_commit.message, '[skip ci]') &&
!startsWith(github.event.head_commit.message, 'chore: release') &&
!startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Test
run: make test
- name: Build
run: bun run build
- name: Generate canary version
id: version
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
TIMESTAMP=$(date +%Y%m%d%H%M%S)
CANARY_VERSION_SUFFIX="-canary.${TIMESTAMP}.${COMMIT_SHA}"
echo "canary_version_suffix=${CANARY_VERSION_SUFFIX}" >> $GITHUB_OUTPUT
echo "Generated canary version suffix: ${CANARY_VERSION_SUFFIX}"
- name: Update package.json version
run: |
bun --bun -e "
const pkg = require('./package.json');
pkg.version = pkg.version + '${{ steps.version.outputs.canary_version_suffix }}';
console.log('Canary version:', pkg.version);
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
"
- uses: actions/setup-node@v5
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Update npm
run: npm install -g npm@latest
- name: Publish canary release
run: npm publish --tag canary --access public
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Test
run: make test
- name: Build
run: bun run build
- uses: actions/setup-node@v5
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Update npm
run: npm install -g npm@latest
- name: Publish release
run: npm publish --tag latest --access public
- name: Create Github Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref }}
name: ${{ github.ref_name }}
draft: true
prerelease: false
generate_release_notes: true
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}