@@ -3,34 +3,51 @@ name: CD
33on :
44 release :
55 types :
6- - created # Trigger this workflow when a new release is created
6+ - created # Trigger this workflow only when a new release is created
7+
8+ permissions :
9+ contents : write
10+ checks : write
11+ actions : read
12+ issues : read
13+ packages : write
14+ pull-requests : read
15+ repository-projects : read
16+ statuses : read
717
818jobs :
9- # Build and release binaries for Linux and Windows
10- linux_windows :
19+ linux_builds :
1120 runs-on : ubuntu-latest
12- permissions :
13- contents : write
14- checks : write
15-
16- actions : read
17- issues : read
18- packages : write
19- pull-requests : read
20- repository-projects : read
21- statuses : read
2221 steps :
2322 - name : Checkout the repository
2423 uses : actions/checkout@v2 # Checkout the repository to the runner
2524
26- - name : Install Linux and Windows Cross Compilers
27- run : sudo apt-get install --yes --no-install-recommends musl-tools gcc-mingw-w64-x86-64-win32 # Install necessary cross-compilers for Linux and Windows
25+ - name : Install Linux Cross Compilers
26+ run : |
27+ sudo apt-get update
28+ sudo apt-get install -y \
29+ gcc-aarch64-linux-gnu \
30+ g++-aarch64-linux-gnu \
31+ binutils-aarch64-linux-gnu \
32+ libgcc-9-dev-arm64-cross \
33+ libstdc++-9-dev-arm64-cross \
34+
2835
2936 - name : Install rustup targets
30- run : rustup target add x86_64-unknown-linux-musl x86_64-pc-windows -gnu
37+ run : rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux -gnu
3138
32- - name : Build the executable
33- run : cargo build --release --target x86_64-unknown-linux-musl --target x86_64-pc-windows-gnu # Build the executable for both Linux and Windows targets
39+ - name : Build x86_64 binary
40+ run : cargo build --release --target=x86_64-unknown-linux-gnu
41+
42+ - name : Set up environment for cross-compilation
43+ run : |
44+ echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
45+ echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
46+ echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
47+
48+ - name : Build aarch64 binary
49+ run : |
50+ cargo build --release --target=aarch64-unknown-linux-gnu
3451
3552 - name : Build release name
3653 run : |
@@ -42,45 +59,35 @@ jobs:
4259 - name : Tar x86_64 binary
4360 run : |
4461 PKG_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
45- tar -czvf ${{ env.RELEASE_NAME }}-gnu-linux-x86_64.tar.gz -C target/x86_64-unknown-linux-musl /release ${PKG_NAME}
62+ tar -czvf ${{ env.RELEASE_NAME }}-gnu-linux-x86_64.tar.gz -C target/x86_64-unknown-linux-gnu /release ${PKG_NAME}
4663
47- - name : Zip windows binary
64+ - name : Tar arm64 binary
4865 run : |
4966 PKG_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
50- zip -j ${{ env.RELEASE_NAME }}-windows.zip target/x86_64-pc-windows-gnu/release/${PKG_NAME}.exe
67+ tar -czvf ${{ env.RELEASE_NAME }}-gnu-linux-aarch64.tar.gz -C target/aarch64-unknown-linux-gnu/release ${PKG_NAME}
68+
5169
5270 - name : Generate SHA256 checksums
5371 run : |
5472 shasum -a 256 ${{ env.RELEASE_NAME }}-gnu-linux-x86_64.tar.gz > ${{ env.RELEASE_NAME }}-gnu-linux-x86_64.tar.gz.sha256
55- shasum -a 256 ${{ env.RELEASE_NAME }}-windows.zip > ${{ env.RELEASE_NAME }}-windows.zip .sha256
56-
73+ shasum -a 256 ${{ env.RELEASE_NAME }}-gnu-linux-aarch64.tar.gz > ${{ env.RELEASE_NAME }}-gnu-linux-aarch64.tar.gz .sha256
74+
5775 - name : Upload release binaries
5876 uses : softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # Use the third party action to upload the release binaries
5977 env :
6078 GITHUB_TOKEN : ${{ github.token }} # Use the GitHub token for authentication
6179 with :
6280 files : |
6381 ${{ env.RELEASE_NAME }}-gnu-linux-x86_64.tar.gz
64- ${{ env.RELEASE_NAME }}-windows.zip
6582 ${{ env.RELEASE_NAME }}-gnu-linux-x86_64.tar.gz.sha256
66- ${{ env.RELEASE_NAME }}-windows.zip.sha256
83+ ${{ env.RELEASE_NAME }}-gnu-linux-aarch64.tar.gz
84+ ${{ env.RELEASE_NAME }}-gnu-linux-aarch64.tar.gz.sha256
6785
68- # Build and release binaries for MacOS (x86_64 and arm64)
69- macos :
86+ macos_builds :
7087 runs-on : macos-latest
71- permissions :
72- contents : write
73- checks : write
74-
75- actions : read
76- issues : read
77- packages : write
78- pull-requests : read
79- repository-projects : read
80- statuses : read
8188 steps :
8289 - name : Checkout the repository
83- uses : actions/checkout@v2
90+ uses : actions/checkout@v2 # Checkout the repository to the runner
8491
8592 - name : Install rustup targets
8693 run : rustup target add x86_64-apple-darwin aarch64-apple-darwin
@@ -119,16 +126,55 @@ jobs:
119126 ${{ env.RELEASE_NAME }}-macos-aarch64.tar.gz
120127 ${{ env.RELEASE_NAME }}-macos-x86_64.tar.gz.sha256
121128 ${{ env.RELEASE_NAME }}-macos-aarch64.tar.gz.sha256
122- # crates:
123- # runs-on: ubuntu-latest
124- # needs: [linux_windows, macos]
125- # steps:
126- # - name: Publish to crates.io
127- # - uses: actions/checkout@v3
128- # - uses: actions-rs/toolchain@v1
129- # with:
130- # toolchain: stable
131- # override: true
132- # - uses: katyo/publish-crates@v2
133- # with:
134- # registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
129+
130+ windows_builds :
131+ runs-on : windows-latest
132+ steps :
133+ - name : Checkout the repository
134+ uses : actions/checkout@v2 # Checkout the repository to the runner
135+
136+ - name : Install rustup targets
137+ run : rustup target add x86_64-pc-windows-msvc aarch64-pc-windows-msvc
138+ shell : pwsh
139+
140+ - name : Build the executable
141+ run : |
142+ cargo build --release --target=x86_64-pc-windows-msvc --target=aarch64-pc-windows-msvc
143+ shell : pwsh
144+
145+ - name : Build release name
146+ run : |
147+ $PKG_NAME = (cargo metadata --no-deps --format-version 1 | ConvertFrom-Json).packages[0].name
148+ $PKG_VERSION = (cargo metadata --no-deps --format-version 1 | ConvertFrom-Json).packages[0].version
149+ $RELEASE_NAME = "${PKG_NAME}_${PKG_VERSION}"
150+ echo "RELEASE_NAME=$RELEASE_NAME" | Out-File -FilePath $Env:GITHUB_ENV -Append
151+ shell : pwsh
152+
153+ - name : Zip Windows x86_64 binary
154+ run : |
155+ $PKG_NAME = (cargo metadata --no-deps --format-version 1 | ConvertFrom-Json).packages[0].name
156+ & 7z a "$Env:RELEASE_NAME-windows-x86_64.zip" "target/x86_64-pc-windows-msvc/release/$PKG_NAME.exe"
157+ shell : pwsh
158+
159+ - name : Zip Windows ARM64 binary
160+ run : |
161+ $PKG_NAME = (cargo metadata --no-deps --format-version 1 | ConvertFrom-Json).packages[0].name
162+ & 7z a "$Env:RELEASE_NAME-windows-aarch64.zip" "target/aarch64-pc-windows-msvc/release/$PKG_NAME.exe"
163+ shell : pwsh
164+
165+ - name : Generate SHA256 checksums
166+ run : |
167+ Get-FileHash -Algorithm SHA256 "$Env:RELEASE_NAME-windows-x86_64.zip" | Format-List | Out-File "$Env:RELEASE_NAME-windows-x86_64.zip.sha256"
168+ Get-FileHash -Algorithm SHA256 "$Env:RELEASE_NAME-windows-aarch64.zip" | Format-List | Out-File "$Env:RELEASE_NAME-windows-aarch64.zip.sha256"
169+ shell : pwsh
170+
171+ - name : Upload release binaries to GitHub
172+ uses : softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda
173+ env :
174+ GITHUB_TOKEN : ${{ github.token }}
175+ with :
176+ files : |
177+ ${{ env.RELEASE_NAME }}-windows-x86_64.zip
178+ ${{ env.RELEASE_NAME }}-windows-aarch64.zip
179+ ${{ env.RELEASE_NAME }}-windows-x86_64.zip.sha256
180+ ${{ env.RELEASE_NAME }}-windows-aarch64.zip.sha256
0 commit comments