-
Notifications
You must be signed in to change notification settings - Fork 4
145 lines (128 loc) · 4.4 KB
/
release.yml
File metadata and controls
145 lines (128 loc) · 4.4 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
name: Release
on:
push:
branches:
- main
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact_name: componentize-go
asset_name: componentize-go-linux-amd64
# Linux aarch64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact_name: componentize-go
asset_name: componentize-go-linux-arm64
# macOS x86_64
- target: x86_64-apple-darwin
os: macos-latest
artifact_name: componentize-go
asset_name: componentize-go-darwin-amd64
# macOS aarch64
- target: aarch64-apple-darwin
os: macos-latest
artifact_name: componentize-go
asset_name: componentize-go-darwin-arm64
# Windows x86_64
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact_name: componentize-go.exe
asset_name: componentize-go-windows-amd64
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust
run: |
rustup update stable --no-self-update
rustup default stable
rustup target add ${{ matrix.target }}
- name: Install cross-compilation tools (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Strip binary (Linux and macOS)
if: runner.os != 'Windows'
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
else
strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
fi
- name: Upload binary
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.asset_name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: Flatten, rename, and compress artifacts
run: |
mkdir -p release
for dir in artifacts/*/; do
asset_name=$(basename "$dir")
binary=$(ls "$dir")
if [[ "$asset_name" == *windows* ]]; then
cd "$dir"
zip -9 "../../release/${asset_name}.zip" "$binary"
cd ../..
else
cd "$dir"
tar -czvf "../../release/${asset_name}.tar.gz" "$binary"
cd ../..
fi
done
- name: Generate checksums
run: |
cd release
sha256sum * > checksums.txt
- name: Create Release (tagged)
if: startsWith(github.ref, 'refs/tags/')
run: gh release create --generate-notes ${{ github.ref_name }} release/*
env:
GH_TOKEN: ${{ github.token }}
- name: Create/Update Canary Release
if: github.ref == 'refs/heads/main'
run: |
# Delete existing canary release if it exists
gh release delete canary --yes || true
# Delete existing canary tag if it exists
git push origin :refs/tags/canary || true
# Create new canary release
gh release create canary \
--title "Canary Release" \
--notes "**This is an unstable canary release built from the latest \`main\` branch.**
Commit: ${{ github.sha }}
Built: $(date -u +'%Y-%m-%d %H:%M:%S UTC')
This release is automatically updated on every push to \`main\`. Use tagged releases for stable versions." \
--prerelease \
release/*
env:
GH_TOKEN: ${{ github.token }}