Skip to content

Commit

Permalink
release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvankodev committed Nov 7, 2024
1 parent 2e12a41 commit a5ecb4e
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
on:
release:
types: [created]

jobs:
release:
name: release ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
archive: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-gnu
os: windows-latest
archive: zip

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
shared-key: ${{matrix.target}}-cache

- name: Compile binaries
run: |
cargo build --verbose --release
if [ "${{ matrix.os }}" = "windows-latest" ]; then
bin="target/release/metaframer.exe"
else
bin="target/release/metaframer"
fi
echo "BIN=$bin" >> $GITHUB_ENV
- name: Determine archive name
run: |
echo "ARCHIVE=metaframer-${{ github.event.tag_name }}-${{ matrix.target }}" >> $GITHUB_ENV
- name: Create archive
run: |
mkdir -p "$ARCHIVE"
cp "$BIN" "$ARCHIVE"/
cp {README.md,LICENSE} "$ARCHIVE"/
- name: Build archive (zip)
shell: bash
if: matrix.archive == 'zip'
run: |
7z a "$ARCHIVE.zip" "$ARCHIVE"
certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256"
echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV
echo "ASSET_SUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV
- name: Build archive (Unix)
shell: bash
if: matrix.archive == 'tar.gz'
run: |
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"
echo "ASSET=$ARCHIVE.tar.gz" >> $GITHUB_ENV
echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >> $GITHUB_ENV
- name: Upload release archive
run: gh release upload "${{ github.event.tag_name }}" ${{ env.ASSET }} ${{ env.ASSET_SUM }}

0 comments on commit a5ecb4e

Please sign in to comment.