-
Notifications
You must be signed in to change notification settings - Fork 31
149 lines (122 loc) · 4.02 KB
/
release.yml
File metadata and controls
149 lines (122 loc) · 4.02 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Release
on:
push:
branches:
- master
permissions:
contents: write
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Lint
run: bun run lint
- name: Type check
run: bun run typecheck
- name: Test
run: bun test
- name: Check documentation
run: bun run check-docs
determine-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine next version
id: version
run: |
# Get the latest version tag (e.g., v0.2.0)
LATEST_TAG=$(git tag --list 'v*' --sort=-version:refname | head -n 1)
if [ -z "$LATEST_TAG" ]; then
# No tags exist — use package.json version as the starting point
CURRENT=$(jq -r .version package.json)
echo "No existing tags found, using package.json version: $CURRENT"
else
# Strip the leading 'v'
CURRENT="${LATEST_TAG#v}"
echo "Latest tag: $LATEST_TAG (version: $CURRENT)"
fi
# Bump patch version: split on dots, increment the last segment
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
NEXT_PATCH=$((PATCH + 1))
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
NEXT_TAG="v${NEXT_VERSION}"
echo "Next version: $NEXT_VERSION (tag: $NEXT_TAG)"
echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$NEXT_TAG" >> "$GITHUB_OUTPUT"
build:
needs: [ci, determine-version]
strategy:
matrix:
include:
- target: bun-linux-x64
artifact: recs-linux-x64
os: ubuntu-latest
- target: bun-linux-arm64
artifact: recs-linux-arm64
os: ubuntu-latest
- target: bun-darwin-x64
artifact: recs-darwin-x64
os: macos-latest
- target: bun-darwin-arm64
artifact: recs-darwin-arm64
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Stamp version in package.json
run: |
jq '.version = "${{ needs.determine-version.outputs.version }}"' package.json > package.json.tmp
mv package.json.tmp package.json
- name: Build binary
run: bun build ./bin/recs.ts --compile --target=${{ matrix.target }} --outfile=${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
release:
needs: [determine-version, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create tag
run: |
git tag "${{ needs.determine-version.outputs.tag }}"
git push origin "${{ needs.determine-version.outputs.tag }}"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.determine-version.outputs.tag }}
name: ${{ needs.determine-version.outputs.tag }}
generate_release_notes: true
files: |
artifacts/recs-linux-x64/recs-linux-x64
artifacts/recs-linux-arm64/recs-linux-arm64
artifacts/recs-darwin-x64/recs-darwin-x64
artifacts/recs-darwin-arm64/recs-darwin-arm64