-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (93 loc) · 3.1 KB
/
release.yml
File metadata and controls
108 lines (93 loc) · 3.1 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: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build release asset (${{ matrix.label }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-14
label: macOS arm64
artifact_name: insert-dylib-macos-aarch64
binary_name: insert-dylib
archive_glob: dist/*.tar.gz
- os: ubuntu-latest
label: Linux x86_64
artifact_name: insert-dylib-linux-x86_64
binary_name: insert-dylib
archive_glob: dist/*.tar.gz
- os: windows-latest
label: Windows x86_64
artifact_name: insert-dylib-windows-x86_64
binary_name: insert-dylib.exe
archive_glob: dist/*.zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
- name: Build release binary
run: cargo build --release
- name: Package archive
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
package_dir="${{ matrix.artifact_name }}"
mkdir -p dist "$package_dir"
cp "target/release/${{ matrix.binary_name }}" "$package_dir/"
cp README.md README.cn.md LICENSE "$package_dir/"
tar -czf "dist/${package_dir}.tar.gz" "$package_dir"
- name: Package archive
if: runner.os == 'Windows'
shell: pwsh
run: |
$packageDir = "${{ matrix.artifact_name }}"
New-Item -ItemType Directory -Force -Path "dist" | Out-Null
New-Item -ItemType Directory -Force -Path $packageDir | Out-Null
Copy-Item "target/release/${{ matrix.binary_name }}" $packageDir
Copy-Item README.md, README.cn.md, LICENSE $packageDir
Compress-Archive -Path "$packageDir/*" -DestinationPath "dist/$packageDir.zip" -Force
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.archive_glob }}
publish:
name: Publish GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download built artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten artifacts
run: |
set -euo pipefail
mkdir -p release-files
find dist -type f \( -name '*.tar.gz' -o -name '*.zip' \) -exec cp {} release-files/ \;
- name: Generate SHA256 checksums
run: |
set -euo pipefail
cd release-files
sha256sum *.tar.gz *.zip > SHA256SUMS.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
release-files/*.tar.gz
release-files/*.zip
release-files/SHA256SUMS.txt
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}