-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (147 loc) · 6.14 KB
/
release.yml
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
name: Release
on:
push:
tags: [v*]
env:
CARGO: cargo
CROSS_VERSION: v0.2.5
RELEASE_BIN: pass-it-on-cli
RELEASE_DIR: artifacts
UPLOAD_DIR: upload
# Space separated paths to include in the archive.
RELEASE_ADDS: README.md CHANGELOG.md LICENSE
jobs:
build:
name: Build Artifacts
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
rust: stable
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
rust: stable
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
rust: stable
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
rust: stable
- target: x86_64-pc-windows-msvc
os: windows-latest
rust: stable
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- name: Create artifact directory
shell: bash
run: |
mkdir -p ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}
mkdir ${{ env.UPLOAD_DIR }}
cp -v ${{ env.RELEASE_ADDS }} ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}
- name: Setup Cross
if: matrix.os == 'ubuntu-latest' && matrix.target != 'x86_64-unknown-linux-gnu'
run: |
dir="$RUNNER_TEMP/cross-download"
mkdir "$dir"
echo "$dir" >> $GITHUB_PATH
cd "$dir"
curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz"
tar xf cross-x86_64-unknown-linux-musl.tar.gz
echo "CARGO=cross" >> $GITHUB_ENV
- name: Build Binary
run: ${{ env.CARGO }} build --release --bins --all-features --target ${{ matrix.target }}
- name: Prepare Linux Binaries
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
mv -v target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}
cd ${{ env.RELEASE_DIR }}
ls -lhR
tar -vcaf ${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}
mv -v ${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ../${{ env.UPLOAD_DIR }}
- name: Prepare Windows Binaries
if: matrix.os == 'windows-latest'
shell: bash
run: |
mv -v target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }}.exe ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}
cd ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}
7z a -tzip ./${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}.zip .
mv -v ${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}.zip ../../${{ env.UPLOAD_DIR }}
- name: Upload Linux Archive
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_BIN }}-${{ matrix.target }}
path: ${{ env.UPLOAD_DIR }}/${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
- name: Upload Windows Archive
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_BIN }}-${{ matrix.target }}
path: ${{ env.UPLOAD_DIR }}/${{ env.RELEASE_BIN }}-${{ github.ref_name }}-${{ matrix.target }}.zip
release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ env.RELEASE_BIN }}-*
- name: Prepare Artifacts
shell: bash
run: |
for d in ${{ env.RELEASE_BIN }}-* ; do mv -v $d/${{ env.RELEASE_BIN }}* . ; done
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
generate_release_notes: true
fail_on_unmatched_files: true
files: ./${{ env.RELEASE_BIN }}-${{ github.ref_name }}-*
- name: Generate Checksum
shell: bash
run: |
curl -L "${{ github.server_url }}/${{ github.repository }}/archive/refs/tags/${{ github.ref_name }}.tar.gz" -o ${{ github.event.repository.name }}-${{ github.ref_name }}.tar.gz
sha512sum *.tar.gz >> checksum.sha512
sha512sum *.zip >> checksum.sha512
b2sum *.tar.gz >> checksum.b2sum
b2sum *.zip >> checksum.b2sum
- name: Upload Checksum sha512
uses: sekwah41/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./checksum.sha512
asset_name: ${{ github.event.repository.name }}-checksum.sha512
asset_content_type: text/plain
- name: Upload Checksum blake2
uses: sekwah41/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./checksum.b2sum
asset_name: ${{ github.event.repository.name }}-checksum.b2sum
asset_content_type: text/plain
- name: Upload Static Checksum Source
uses: sekwah41/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}-${{ github.ref_name }}.tar.gz
asset_name: ${{ github.event.repository.name }}-${{ github.ref_name }}.tar.gz
asset_content_type: application/gzip