-
Notifications
You must be signed in to change notification settings - Fork 4
185 lines (163 loc) · 5.79 KB
/
release.yml
File metadata and controls
185 lines (163 loc) · 5.79 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
type: string
# Cancel in-progress runs when new commits are pushed
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
permissions:
contents: write
env:
CARGO_PROFILE_DEV_DEBUG: line-tables-only
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get version
id: get_version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Generate release notes
id: release_notes
run: |
echo "# Release ${{ steps.get_version.outputs.version }}" > release_notes.md
echo "" >> release_notes.md
echo "## Changes" >> release_notes.md
# Get the previous tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [[ -n "$PREVIOUS_TAG" ]]; then
echo "Changes since $PREVIOUS_TAG:" >> release_notes.md
git log --oneline --format="- %s" $PREVIOUS_TAG..HEAD >> release_notes.md
else
echo "Initial release" >> release_notes.md
git log --oneline --format="- %s" >> release_notes.md
fi
- name: Create Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.get_version.outputs.version }}" \
--title "Release ${{ steps.get_version.outputs.version }}" \
--notes-file release_notes.md \
--draft=false \
--prerelease=false
build-release:
name: Build Release
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary: debtmap
archive: tar.gz
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
binary: debtmap
archive: tar.gz
- os: macos-latest
target: x86_64-apple-darwin
binary: debtmap
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
binary: debtmap
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
binary: debtmap.exe
archive: zip
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools pkg-config
- name: Install OpenSSL (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
echo "Installing OpenSSL via vcpkg..."
vcpkg integrate install
vcpkg install openssl:x64-windows-static-md
$opensslDir = "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows-static-md"
echo "OPENSSL_DIR=$opensslDir" >> $env:GITHUB_ENV
echo "OPENSSL_LIB_DIR=$opensslDir\lib" >> $env:GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=$opensslDir\include" >> $env:GITHUB_ENV
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
env:
OPENSSL_STATIC: ${{ matrix.target == 'x86_64-unknown-linux-musl' && '1' || '' }}
- name: Create archive (Unix)
if: matrix.archive == 'tar.gz'
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/${{ matrix.binary }} release/
cp README.md LICENSE release/
cd release
tar -czf ../debtmap-${{ matrix.target }}.tar.gz .
- name: Create archive (Windows)
if: matrix.archive == 'zip'
run: |
mkdir release
cp target/${{ matrix.target }}/release/${{ matrix.binary }} release/
cp README.md release/
cp LICENSE release/
cd release
7z a ../debtmap-${{ matrix.target }}.zip .
- name: Generate checksums
shell: bash
run: |
if [[ "${{ matrix.archive }}" == "tar.gz" ]]; then
if [[ "${{ runner.os }}" == "macOS" ]]; then
shasum -a 256 debtmap-${{ matrix.target }}.tar.gz > debtmap-${{ matrix.target }}.tar.gz.sha256
else
sha256sum debtmap-${{ matrix.target }}.tar.gz > debtmap-${{ matrix.target }}.tar.gz.sha256
fi
else
if [[ "${{ runner.os }}" == "Windows" ]]; then
powershell -Command "Get-FileHash -Algorithm SHA256 debtmap-${{ matrix.target }}.zip | ForEach-Object { \$_.Hash.ToLower() + ' ' + \$_.Path.Split('\')[-1] }" > debtmap-${{ matrix.target }}.zip.sha256
else
sha256sum debtmap-${{ matrix.target }}.zip > debtmap-${{ matrix.target }}.zip.sha256
fi
fi
- name: Upload Release Assets
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${{ matrix.archive }}" == "tar.gz" ]]; then
gh release upload "${{ needs.create-release.outputs.version }}" \
"debtmap-${{ matrix.target }}.tar.gz" \
"debtmap-${{ matrix.target }}.tar.gz.sha256"
else
gh release upload "${{ needs.create-release.outputs.version }}" \
"debtmap-${{ matrix.target }}.zip" \
"debtmap-${{ matrix.target }}.zip.sha256"
fi