-
Notifications
You must be signed in to change notification settings - Fork 22
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
2 changed files
with
91 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,43 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
# Slightly tweaked from https://github.com/EmbarkStudios/cargo-about/blob/main/.github/workflows/rust-ci.yml (MIT LICENSE) | ||
# When run in a container, the ownership will be messed up, so mark the | ||
# checkout dir as safe regardless of our env | ||
git config --global --add safe.directory "$GITHUB_WORKSPACE" | ||
|
||
# Normally we'll only do this on tags, but add --always to fallback to the revision | ||
# if we're iterating or the like | ||
tag=$(git describe --tags --abbrev=0 --always) | ||
|
||
if [[ ${tag:0:1} != "v" ]]; then | ||
tag="nightly" | ||
fi | ||
|
||
release_name="$NAME-$tag-$TARGET" | ||
release_zip="${release_name}.zip" | ||
release_tar="${release_name}.tar.gz" | ||
|
||
mkdir "$release_name" | ||
|
||
if [[ "$TARGET" =~ windows ]]; then | ||
bin="$NAME.exe" | ||
cp "examples/target/$TARGET/release-action/$bin" "$release_name/" | ||
cp README.md LICENSE "$release_name/" | ||
7z a -tzip "$release_zip" "$release_name" | ||
else | ||
bin="$NAME" | ||
cp "examples/target/$TARGET/release-action/$bin" "$release_name/" | ||
cp README.md LICENSE "$release_name/" | ||
tar czf "$release_tar" "$release_name" | ||
fi | ||
|
||
rm -r "$release_name" | ||
|
||
# Windows environments in github actions don't have the gnu coreutils installed, | ||
# which includes the shasum exe, so we just use powershell instead | ||
if [[ "$TARGET" =~ windows ]]; then | ||
echo "(Get-FileHash \"${release_zip}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_zip}.sha256\"" | pwsh -c - | ||
else | ||
echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256" | ||
fi |
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,48 @@ | ||
name: Release Example Binary | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.* | ||
|
||
jobs: | ||
upload-release: | ||
strategy: | ||
matrix: | ||
info: | ||
- os: "macOS-latest" | ||
target: "x86_64-apple-darwin" | ||
- os: "macOS-latest" | ||
target: "aarch64-apple-darwin" | ||
- os: "windows-latest" | ||
target: "x86_64-pc-windows-msvc" | ||
- os: "ubuntu-latest" | ||
target: "x86_64-unknown-linux-gnu" | ||
runs-on: ${{ matrix.info.os }} | ||
steps: | ||
- name: Setup Stable Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.info.target }} | ||
components: clippy, rustfmt | ||
|
||
- name: Build Example | ||
run: cd examples && cargo build --release --target ${{ matrix.info.target }} | ||
|
||
- name: Package Example | ||
shell: bash | ||
env: | ||
NAME: unifiedlog_iterator | ||
TARGET: ${{ matrix.info.target }} | ||
run: .github/scripts/package.sh | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: "unifiedlog_iterator*" | ||
name: "${{ vars.GITHUB_REF_NAME }} - Released!" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |