Update README (#5) #18
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
name: Post-merge Test and Release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
test: | |
uses: ./.github/workflows/run-tests.yml | |
check-for-release: | |
name: Check if release required | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
outputs: | |
release: "${{ steps.tag-release.outputs.release }}" | |
version: "${{ steps.tag-release.outputs.version }}" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- shell: bash | |
id: tag-release | |
name: tag-release | |
run: | | |
VERSION=$(yq -oy '.package.version' Cargo.toml) | |
if git tag --list | grep "^$VERSION\$" >>/dev/null 2>&1; then | |
echo "Version $VERSION already tagged, no release to complete" | |
echo "release=false" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
echo "Continuing to create release tag for $VERSION" | |
echo "release=true" >> $GITHUB_OUTPUT | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
build-and-upload: | |
if: ${{ needs.check-for-release.outputs.release == 'true' }} | |
needs: check-for-release | |
name: Build and Upload | |
runs-on: ${{ matrix.os }} | |
permissions: | |
contents: write | |
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 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Build Release Binaries | |
shell: bash | |
run: | | |
cargo build --release --target ${{ matrix.target }} | |
- name: Create Release Archives | |
shell: bash | |
run: | | |
binary_name="bridgeboard-pc-boot-patcher" | |
dirname="$binary_name-${{ needs.check-for-release.outputs.version }}-${{ matrix.build }}" | |
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: | |
name: ${{ needs.check-for-release.outputs.version }} | |
tag_name: ${{ needs.check-for-release.outputs.version }} | |
generate_release_notes: true | |
files: | | |
${{ env.ASSET }} |