-
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.
Cross platform tests and release workflow (#2)
* Add cross-platform tests * Add release workflows
- Loading branch information
Showing
3 changed files
with
154 additions
and
6 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,46 @@ | ||
name: Test and Tag | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/run-tests.yml | ||
|
||
check-for-and-create-new-release: | ||
name: Create new release tag if needed | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- shell: bash | ||
run: | | ||
VERSION=$(yq -oy '.package.version' Cargo.toml) | ||
echo "Checking for version $VERSION" | ||
git tag --list | ||
echo "With grep" | ||
git tag --list | grep "^$VERSION\$" | ||
if git tag --list | grep "^$VERSION\$" >>/dev/null 2>&1; then | ||
echo "Version $VERSION already tagged, no release to complete" | ||
exit 0 | ||
fi | ||
echo "Continuing to create release tag" | ||
git config user.name BridgeBoard-PC-Boot-Patcher-AutoRelease | ||
git tag "$VERSION" | ||
git push origin "$VERSION" |
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,81 @@ | ||
# Thanks to https://dzfrias.dev/blog/deploy-rust-cross-platform-github-actions on which | ||
# most of this workflow was based | ||
name: Create Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "[0-9]+.[0-9]+.[0-9]+" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build-and-upload: | ||
name: Build and Upload | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- build: linux | ||
os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
|
||
- build: macos-x86_64 | ||
os: macos-latest | ||
target: x86_64-apple-darwin | ||
|
||
# Can build, but not test | ||
- build: macos-arm64 | ||
os: macos-latest | ||
target: aarch64-apple-darwin | ||
|
||
- build: windows | ||
os: windows-latest | ||
target: x86_64-pc-windows-gnu | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get the release version from the tag | ||
shell: bash | ||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
|
||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
|
||
- name: Release build | ||
shell: bash | ||
run: | | ||
cargo build --release --target ${{ matrix.target }} | ||
- name: Build archive | ||
shell: bash | ||
run: | | ||
binary_name="bridgeboard-pc-boot-patcher" | ||
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" | ||
mkdir "$dirname" | ||
if [ "${{ matrix.os }}" = "windows-latest" ]; then | ||
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" | ||
else | ||
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" | ||
fi | ||
if [ "${{ matrix.os }}" = "windows-latest" ]; then | ||
7z a "$dirname.zip" "$dirname" | ||
echo "ASSET=$dirname.zip" >> $GITHUB_ENV | ||
else | ||
tar -czf "$dirname.tar.gz" "$dirname" | ||
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV | ||
fi | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
${{ env.ASSET }} |
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 |
---|---|---|
@@ -1,21 +1,42 @@ | ||
# Thanks to https://dzfrias.dev/blog/deploy-rust-cross-platform-github-actions on which | ||
# most of this workflow was based | ||
name: Run Tests | ||
|
||
on: | ||
workflow_call: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
name: cargo test | ||
runs-on: ubuntu-latest | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- build: linux-x86_64 | ||
os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
|
||
- build: macos-x86_64 | ||
os: macos-latest | ||
target: x86_64-apple-darwin | ||
|
||
- build: windows-gnu-x86_64 | ||
os: windows-latest | ||
target: x86_64-pc-windows-gnu | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- run: cargo test --all-features | ||
- name: Install rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
- name: Run tests | ||
shell: bash | ||
run: | | ||
cargo test --target "${{ matrix.target }}" --all-features | ||