-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
152 additions
and
26 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,91 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
|
||
jobs: | ||
upload-binaries: | ||
name: Upload Binaries | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set release version | ||
run: echo "RELEASE_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV | ||
|
||
- name: Install Zig | ||
uses: goto-bus-stop/setup-zig@v2 | ||
with: | ||
version: 0.12.0 | ||
|
||
- name: Print Zig meta | ||
run: | | ||
zig version | ||
zig env | ||
# Build binaries for target queries in `build.zig`, contents | ||
# will be saved in `zig-out` | ||
- name: Build release binaries | ||
run: | | ||
rm -rf zig-out # sanity | ||
zig build release --summary all | ||
# Rename binary folders with name-version prefix, and copy | ||
# other assets into individual release folders. | ||
- name: Collect assets | ||
shell: bash | ||
run: | | ||
version_prefix="fex-${{ env.RELEASE_VERSION }}-" | ||
for build_path in "zig-out"/*; do | ||
echo "Collecting $build_path" | ||
# Rename folder | ||
new_folder_name=$version_prefix$(basename $build_path) | ||
new_build_path="zig-out/$new_folder_name" | ||
mv "$build_path" "$new_build_path" | ||
# Copy assets into release folders | ||
cp {LICENSE,README.md} "$new_build_path" | ||
cp -r shell/. "$new_build_path" | ||
done | ||
# Create tar.gz of release folders, and calculate their | ||
# checksums. Output is stored in `release`. | ||
- name: Prepare artifacts | ||
shell: bash | ||
run: | | ||
mkdir -p release && cd release | ||
for asset in "../zig-out"/*; do | ||
echo "Preparing $asset" | ||
asset_name=$(basename $asset) | ||
tar_name=${asset_name}.tar.gz | ||
tar -C ../zig-out -czvf $tar_name $asset_name | ||
shasum -a 512 $tar_name > ${tar_name}.sha512 | ||
done | ||
# Creates a new release and uploads artifacts to it. | ||
- name: Upload for release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
file: release/* | ||
file_glob: true | ||
overwrite: true | ||
tag: ${{ github.ref }} | ||
release_name: 'Release v${{ env.RELEASE_VERSION }}' | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: true | ||
|
||
# Upload artifacts to GHA for inspection incase something | ||
# goes wrong. | ||
- name: Upload for inspection | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: release-artifact | ||
path: release/ | ||
retention-days: 3 | ||
overwrite: true | ||
if-no-files-found: error |
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
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