Skip to content

Build & Release

Build & Release #9

Workflow file for this run

name: Release
on:
push:
branches: [ main ]
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
released: ${{ steps.release.outputs.release_created }}
tag: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
config-file: .github/release-please-config.json
build:
needs: release-please
if: needs.release-please.outputs.released == 'true'
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin: pyelevate
ext: ""
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
bin: pyelevate.exe
ext: ".exe"
archive: zip
- os: macos-latest
target: aarch64-apple-darwin
bin: pyelevate
ext: ""
archive: tar.gz
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: rustup target add ${{ matrix.target }}
- run: cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
VERSION=${{ needs.release-please.outputs.tag }}
NAME=pyelevate-${VERSION}-${{ matrix.target }}
mkdir dist
cp target/${{ matrix.target }}/release/${{ matrix.bin }} dist/
cd dist
if [ "${{ matrix.archive }}" = "zip" ]; then
powershell Compress-Archive -Path * -DestinationPath ../$NAME.zip
else
tar -czf ../$NAME.tar.gz *
fi
cd ..
sha256sum $NAME.* > $NAME.sha256
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release-please.outputs.tag }}
files: |
*.zip
*.tar.gz
*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}