-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (100 loc) · 3.29 KB
/
release.yml
File metadata and controls
114 lines (100 loc) · 3.29 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
name: Release
on:
push:
branches:
- main
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: linux-x64
runner: ubuntu-latest
artifact: spm-linux-x64
- target: darwin-arm64
runner: macos-latest
artifact: spm-darwin-arm64
- target: darwin-x64
runner: macos-latest
artifact: spm-darwin-x64
- target: windows-x64
runner: windows-latest
artifact: spm-windows-x64.exe
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build binary
run: |
case "${{ matrix.target }}" in
linux-x64)
bun build index.ts --compile --target=bun-linux-x64 --outfile dist/spm-linux-x64
;;
darwin-arm64)
bun build index.ts --compile --target=bun-darwin-arm64 --outfile dist/spm-darwin-arm64
;;
darwin-x64)
bun build index.ts --compile --target=bun-darwin-x64 --outfile dist/spm-darwin-x64
;;
windows-x64)
bun build index.ts --compile --target=bun-windows-x64 --outfile dist/spm-windows-x64.exe
;;
esac
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: spm-${{ matrix.target }}
path: dist/${{ matrix.artifact }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
for dir in artifacts/spm-*/; do
cp "$dir"/* release/ 2>/dev/null || true
done
ls -la release/
- name: Determine version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "prerelease=false" >> $GITHUB_OUTPUT
else
VERSION=$(node -p "require('./package.json').version")
SHORT_SHA=$(git rev-parse --short HEAD)
echo "version=${VERSION}-main.${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "tag=v${VERSION}-main.${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
prerelease: ${{ steps.version.outputs.prerelease }}
generate_release_notes: true
files: release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}