-
-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (88 loc) · 2.92 KB
/
Copy pathrelease.yml
File metadata and controls
100 lines (88 loc) · 2.92 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
name: release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build-release:
name: build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_ext: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
asset_ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
asset_ext: zip
steps:
- uses: actions/checkout@v6
- name: install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: cache dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: build release binary
run: cargo build --release --locked --target ${{ matrix.target }}
- name: package asset (unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -eux
STAGE="mew-${{ github.ref_name }}-${{ matrix.target }}"
mkdir -p "$STAGE"
cp "target/${{ matrix.target }}/release/mew" "$STAGE/"
cp README.md LICENSE "$STAGE/" 2>/dev/null || true
tar -czf "$STAGE.tar.gz" "$STAGE"
sha256sum "$STAGE.tar.gz" > "$STAGE.tar.gz.sha256" || shasum -a 256 "$STAGE.tar.gz" > "$STAGE.tar.gz.sha256"
ls -lh "$STAGE.tar.gz"*
- name: package asset (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$Stage = "mew-${{ github.ref_name }}-${{ matrix.target }}"
New-Item -ItemType Directory -Force -Path $Stage | Out-Null
Copy-Item "target/${{ matrix.target }}/release/mew.exe" "$Stage/"
if (Test-Path README.md) { Copy-Item README.md "$Stage/" }
if (Test-Path LICENSE) { Copy-Item LICENSE "$Stage/" }
Compress-Archive -Path $Stage -DestinationPath "$Stage.zip" -Force
$Hash = (Get-FileHash "$Stage.zip" -Algorithm SHA256).Hash.ToLower()
"$Hash $Stage.zip" | Out-File -FilePath "$Stage.zip.sha256" -Encoding ascii
Get-ChildItem "$Stage.zip*"
- name: upload packaged asset
uses: actions/upload-artifact@v4
with:
name: mew-${{ matrix.target }}
path: |
mew-*.tar.gz
mew-*.tar.gz.sha256
mew-*.zip
mew-*.zip.sha256
if-no-files-found: error
publish-release:
name: publish release
runs-on: ubuntu-latest
needs: build-release
steps:
- name: download packaged assets
uses: actions/download-artifact@v4
with:
pattern: mew-*
merge-multiple: true
path: dist
- name: upload release assets
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
files: |
dist/*