Skip to content

Update release.yml

Update release.yml #10

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:
prepare-manifest:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: v
run: |
V=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "version=$V" >> $GITHUB_OUTPUT
echo "{ \".\": \"$V\" }" > .release-please-manifest.json
- uses: actions/upload-artifact@v4
with:
name: manifest
path: .release-please-manifest.json
release-please:
needs: prepare-manifest
runs-on: ubuntu-latest
outputs:
released: ${{ steps.release.outputs.release_created }}
tag: ${{ steps.release.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: manifest
- uses: googleapis/release-please-action@v4
id: release
with:
config-file: .github/release-please-config.json
manifest-file: .release-please-manifest.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
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
bin: pyelevate.exe
archive: zip
- os: macos-latest
target: aarch64-apple-darwin
bin: pyelevate
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 }}