-
Notifications
You must be signed in to change notification settings - Fork 33
163 lines (127 loc) · 5.85 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
on:
workflow_dispatch:
name: Artifacts
env:
RELEASE_BIN: hdr10plus_tool
RELEASE_DIR: artifacts
WINDOWS_TARGET: x86_64-pc-windows-msvc
WINDOWS_ARM_TARGET: aarch64-pc-windows-msvc
MACOS_X86_TARGET: x86_64-apple-darwin
LINUX_TARGET: x86_64-unknown-linux-musl
LINUX_ARM_TARGET: aarch64-unknown-linux-musl
jobs:
linux-binary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-release-env
- name: Install musl-tools
run: |
sudo apt-get update -y
sudo apt-get install musl-tools gcc-aarch64-linux-gnu -y
- name: Build
run: |
rustup target add ${{ env.LINUX_TARGET }}
rustup target add ${{ env.LINUX_ARM_TARGET }}
cargo build --release --target ${{ env.LINUX_TARGET }} --no-default-features --features internal-font
cargo build --config "target.${{ env.LINUX_ARM_TARGET }}.linker = 'aarch64-linux-gnu-gcc'" \
--release --target ${{ env.LINUX_ARM_TARGET }} --no-default-features --features internal-font
- name: Create tarball and checksum
run: |
X86_64_ARCHIVE_FILE=${{ env.RELEASE_DIR }}/${{ env.ARCHIVE_PREFIX }}-${{ env.LINUX_TARGET }}.tar.gz
AARCH64_ARCHIVE_FILE=${{ env.RELEASE_DIR }}/${{ env.ARCHIVE_PREFIX }}-${{ env.LINUX_ARM_TARGET }}.tar.gz
strip ./target/${{ env.LINUX_TARGET }}/release/${{ env.RELEASE_BIN }}
aarch64-linux-gnu-strip ./target/${{ env.LINUX_ARM_TARGET }}/release/${{ env.RELEASE_BIN }}
mv ./target/${{ env.LINUX_TARGET }}/release/${{ env.RELEASE_BIN }} ./${{ env.RELEASE_BIN }}
tar -cvzf ./${X86_64_ARCHIVE_FILE} ./${{ env.RELEASE_BIN }}
mv ./target/${{ env.LINUX_ARM_TARGET }}/release/${{ env.RELEASE_BIN }} ./${{ env.RELEASE_BIN }}
tar -cvzf ./${AARCH64_ARCHIVE_FILE} ./${{ env.RELEASE_BIN }}
python -c "import hashlib; import pathlib; print(hashlib.sha256(pathlib.Path('${X86_64_ARCHIVE_FILE}').read_bytes()).hexdigest())" > ${X86_64_ARCHIVE_FILE}.sha256
python -c "import hashlib; import pathlib; print(hashlib.sha256(pathlib.Path('${AARCH64_ARCHIVE_FILE}').read_bytes()).hexdigest())" > ${AARCH64_ARCHIVE_FILE}.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Linux artifacts
path: ./${{ env.RELEASE_DIR }}/*
windows-binary:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-release-env
- name: Build
run: |
rustup target add ${{ env.WINDOWS_ARM_TARGET }}
cargo build --release
cargo build --release --target ${{ env.WINDOWS_ARM_TARGET }}
- name: Create zipfile
shell: bash
run: |
X86_64_ARCHIVE_FILE=${{ env.RELEASE_DIR }}/${{ env.ARCHIVE_PREFIX }}-${{ env.WINDOWS_TARGET }}.zip
AARCH64_ARCHIVE_FILE=${{ env.RELEASE_DIR }}/${{ env.ARCHIVE_PREFIX }}-${{ env.WINDOWS_ARM_TARGET }}.zip
mv ./target/release/${{ env.RELEASE_BIN }}.exe ./${{ env.RELEASE_BIN }}.exe
7z a ./${X86_64_ARCHIVE_FILE} ./${{ env.RELEASE_BIN }}.exe
mv ./target/${{ env.WINDOWS_ARM_TARGET }}/release/${{ env.RELEASE_BIN }}.exe ./${{ env.RELEASE_BIN }}.exe
7z a ./${AARCH64_ARCHIVE_FILE} ./${{ env.RELEASE_BIN }}.exe
python -c "import hashlib; import pathlib; print(hashlib.sha256(pathlib.Path('${X86_64_ARCHIVE_FILE}').read_bytes()).hexdigest())" > ${X86_64_ARCHIVE_FILE}.sha256
python -c "import hashlib; import pathlib; print(hashlib.sha256(pathlib.Path('${AARCH64_ARCHIVE_FILE}').read_bytes()).hexdigest())" > ${AARCH64_ARCHIVE_FILE}.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Windows artifacts
path: ./${{ env.RELEASE_DIR }}/*
macos-binary:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-release-env
- name: Build
run: |
rustup target add ${{ env.MACOS_X86_TARGET }}
cargo build --release
cargo build --release --target ${{ env.MACOS_X86_TARGET }}
- name: Create universal macOS binary
run: |
strip ./target/release/${{ env.RELEASE_BIN }}
strip ./target/${{ env.MACOS_X86_TARGET }}/release/${{ env.RELEASE_BIN }}
lipo -create \
./target/release/${{ env.RELEASE_BIN }} \
./target/${{ env.MACOS_X86_TARGET }}/release/${{ env.RELEASE_BIN }} \
-output ./${{ env.RELEASE_BIN }}
- name: Create zipfile
run: |
ARCHIVE_FILE=${{ env.RELEASE_DIR }}/${{ env.ARCHIVE_PREFIX }}-universal-macOS.zip
zip -9 ./${ARCHIVE_FILE} ./${{ env.RELEASE_BIN }}
python -c "import hashlib; import pathlib; print(hashlib.sha256(pathlib.Path('${ARCHIVE_FILE}').read_bytes()).hexdigest())" > ${ARCHIVE_FILE}.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macOS artifacts
path: ./${{ env.RELEASE_DIR }}/*
create-release:
needs: [linux-binary, windows-binary, macos-binary]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Display structure of downloaded files
run: ls -R
- name: Attest
uses: actions/attest-build-provenance@v1
with:
subject-path: |
Linux artifacts/*
Windows artifacts/*
macOS artifacts/*
- name: Create a draft release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_PKG_VERSION }}
draft: true
files: |
Linux artifacts/*
Windows artifacts/*
macOS artifacts/*