-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and publish binaries after new release
This new workflow runs after a github release is published. It builds for 5 targets, and after all 5 builds are successful The newly built releases are published to the release tag
- Loading branch information
Showing
3 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Release | ||
permissions: | ||
contents: "write" | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-linux: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
target: ["x86_64-unknown-linux-musl", "aarch64-unknown-linux-gnu"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
- name: Install deps | ||
# cargo-dist uses cargo zigbuild to build for arm/x86 (zig is required to use cargo zigbuild) | ||
# I use brew because I don't think apt has a zig package, and I may as well install cargo zigbuild from brew | ||
run: | | ||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | ||
brew install zig cargo-zigbuild | ||
- name: Build ${{ matrix.target }} | ||
run: | | ||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | ||
cargo zigbuild --release --target ${{ matrix.target }} | ||
./scripts/generate_release_files.sh ${{ matrix.target }} | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ matrix.target }} | ||
path: target/distrib/* | ||
|
||
build-macos: | ||
runs-on: macos-14 | ||
strategy: | ||
matrix: | ||
target: ["aarch64-apple-darwin", "x86_64-apple-darwin"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
- name: Install deps | ||
# cargo-dist uses cargo zigbuild to build for arm/x86 (zig is required to use cargo zigbuild) | ||
# I use brew to install zig and coreutils (sha256sum needs to be installed by coreutils), and I may as well install cargo zigbuild from brew | ||
run: | | ||
brew install zig cargo-zigbuild coreutils | ||
- name: Build ${{ matrix.target }} | ||
run: | | ||
cargo zigbuild --release --target ${{ matrix.target }} | ||
./scripts/generate_release_files.sh ${{ matrix.target }} | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ matrix.target }} | ||
path: target/distrib/* | ||
|
||
build-windows: | ||
runs-on: windows-2022 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: x86_64-pc-windows-msvc | ||
- name: Build x86_64-pc-windows-msvc | ||
run: | | ||
cargo build --release --target x86_64-pc-windows-msvc | ||
bash ./scripts/generate_release_files.sh x86_64-pc-windows-msvc | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-x86_64-pc-windows-msvc | ||
path: target/distrib/* | ||
|
||
publish-artifacts: | ||
runs-on: ubuntu-24.04 | ||
needs: | ||
- build-linux | ||
- build-macos | ||
- build-windows | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Fetch local artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: artifact-* | ||
path: target/distrib/ | ||
merge-multiple: true | ||
- name: Upload files to release | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload ${{ github.event.release.tag_name }} target/distrib/* | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2025 Svix (https://www.svix.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
if [ -z "$1" ] | ||
then | ||
echo "No argument supplied" | ||
exit 1 | ||
fi | ||
|
||
set -eox pipefail | ||
|
||
if [ "$(uname)" == "Darwin" ]; then | ||
TAR_BIN="gtar" | ||
else | ||
TAR_BIN="tar" | ||
fi | ||
|
||
BIN_NAME="openapi-codegen" | ||
mkdir -p target/distrib | ||
|
||
if [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then | ||
PKG_FILENAME="$BIN_NAME-$1.zip" | ||
7z a -tzip \ | ||
"target/distrib/$PKG_FILENAME" \ | ||
README.md \ | ||
LICENSE \ | ||
"./target/$1/release/$BIN_NAME.exe" -w"./target/$1/release" | ||
else | ||
PKG_FILENAME="$BIN_NAME-$1.tar.xz" | ||
$TAR_BIN -czf \ | ||
"target/distrib/$PKG_FILENAME" \ | ||
README.md \ | ||
LICENSE \ | ||
--transform="s|target/$1/release/$BIN_NAME|$BIN_NAME|" \ | ||
"target/$1/release/$BIN_NAME" | ||
fi | ||
|
||
cd target/distrib | ||
sha256sum $PKG_FILENAME > "$PKG_FILENAME.sha256" | ||
|