Skip to content

Commit

Permalink
Fix release workflows and merge down to 1 workflow (#3)
Browse files Browse the repository at this point in the history
* Fix release workflows and merge down to 1 workflow
  • Loading branch information
jfharden authored Jan 29, 2024
1 parent af68ebd commit d867950
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 95 deletions.
96 changes: 82 additions & 14 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test and Tag
name: Post-merge Test and Release

on:
push:
Expand All @@ -12,35 +12,103 @@ jobs:
test:
uses: ./.github/workflows/run-tests.yml

check-for-and-create-new-release:
name: Create new release tag if needed
check-for-release:
name: Check if release required
runs-on: ubuntu-latest
needs:
- test

permissions:
contents: write
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)
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"
echo "release=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Continuing to create release tag"
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

git config user.name BridgeBoard-PC-Boot-Patcher-AutoRelease
- 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 }}
git tag "$VERSION"
git push origin "$VERSION"
- 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 }}
81 changes: 0 additions & 81 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit d867950

Please sign in to comment.