Repository navigation
109 lines (97 loc) · 3.1 KB
/
Copy pathrelease.yml
File metadata and controls
109 lines (97 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
109
name: Release
# Push a tag such as v0.1.1 to build binaries and publish a GitHub release:
# git tag v0.1.1 && git push origin v0.1.1
on:
push:
tags: ["v*"]
env:
CARGO_TERM_COLOR: always
BIN_NAME: zlt_x28_patcher
jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
features: "--features ssh2/vendored-openssl"
archive: tar.gz
- name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
features: ""
archive: zip
- name: macos-arm64
os: macos-latest
target: aarch64-apple-darwin
features: "--features ssh2/vendored-openssl"
archive: tar.gz
- name: macos-x86_64
os: macos-latest
target: x86_64-apple-darwin
features: "--features ssh2/vendored-openssl"
archive: tar.gz
steps:
- uses: actions/checkout@v4
- name: Check tag matches Cargo.toml version
shell: bash
run: |
cargo_version=$(grep -m1 '^version' Cargo.toml | cut -d '"' -f2)
tag_version="${GITHUB_REF_NAME#v}"
if [ "$cargo_version" != "$tag_version" ]; then
echo "Tag ($tag_version) does not match Cargo.toml version ($cargo_version)"
exit 1
fi
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --locked --release --target ${{ matrix.target }} ${{ matrix.features }}
- name: Package
shell: bash
run: |
name="${BIN_NAME}-${GITHUB_REF_NAME}-${{ matrix.name }}"
mkdir "$name"
if [ "${{ matrix.archive }}" = "zip" ]; then
cp "target/${{ matrix.target }}/release/${BIN_NAME}.exe" "$name/"
else
cp "target/${{ matrix.target }}/release/${BIN_NAME}" "$name/"
fi
cp README.md README.fa.md "$name/" 2>/dev/null || true
if [ "${{ matrix.archive }}" = "zip" ]; then
7z a "$name.zip" "$name"
echo "ASSET=$name.zip" >> "$GITHUB_ENV"
else
tar czf "$name.tar.gz" "$name"
echo "ASSET=$name.tar.gz" >> "$GITHUB_ENV"
fi
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ env.ASSET }}
if-no-files-found: error
release:
name: Publish release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create checksums
working-directory: dist
run: sha256sum * > SHA256SUMS.txt
- uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true