feat: Adding self-extracting file as an optional feature #301
Workflow file for this run
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: Build | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
jobs: | |
metadata: | |
name: Check if version changed | |
runs-on: ubuntu-latest | |
outputs: | |
optimize-build: ${{ github.event_name == 'push' }} | |
release: ${{ github.event_name == 'push' && github.repository == 'Quantco/pixi-pack' && steps.version-metadata.outputs.changed == 'true' }} | |
version: ${{ steps.version-metadata.outputs.newVersion }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: Quantco/ui-actions/version-metadata@a0653e9fc0ee3c4be9f7cc88e509e40536e9f3c1 # v1.0.15 | |
id: version-metadata | |
with: | |
file: ./Cargo.toml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
version-extraction-override: 'regex:version = "(.*)"' | |
build: | |
name: Build Binary (${{ matrix.target }}) | |
runs-on: ${{ matrix.os }} | |
needs: [metadata] | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
cross: true | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
cross: true | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
cross: true | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
cross: true | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
cross: false | |
- target: aarch64-pc-windows-msvc | |
os: windows-latest | |
cross: false | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
cross: false | |
- target: x86_64-apple-darwin | |
os: macos-13 | |
cross: false | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Rust cache | |
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 | |
with: | |
key: build-${{ matrix.target }}-${{ needs.metadata.outputs.optimize-build }}-${{ matrix.cross }}-${{ matrix.os }} | |
- name: Install cross | |
if: matrix.cross | |
run: cargo install cross --git https://github.com/cross-rs/cross | |
- name: Build | |
run: | | |
${{ matrix.cross && 'cross' || 'cargo' }} build --profile ${{ needs.metadata.outputs.optimize-build && 'release-min-size' || 'release'}} --color always${{ endsWith(matrix.target, 'musl') && ' --no-default-features --features rustls-tls' || '' }} --target ${{ matrix.target }} | |
mv target/${{ matrix.target }}/${{ needs.metadata.outputs.optimize-build && 'release-min-size' || 'release' }}/pixi-pack${{ endsWith(matrix.target, 'windows-msvc') && '.exe' || '' }} pixi-pack-${{ matrix.target }}${{ endsWith(matrix.target, 'windows-msvc') && '.exe' || '' }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: pixi-pack-${{ matrix.target }} | |
path: pixi-pack-${{ matrix.target }}${{ endsWith(matrix.target, 'windows-msvc') && '.exe' || '' }} | |
if-no-files-found: error | |
release: | |
name: Create Release | |
needs: [metadata, build] | |
if: needs.metadata.outputs.release == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Download artifacts | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
pattern: pixi-pack-* | |
merge-multiple: true | |
- name: Push v${{ needs.metadata.outputs.version }} tag | |
run: | | |
git tag v${{ needs.metadata.outputs.version }} | |
git push origin v${{ needs.metadata.outputs.version }} | |
- name: Create Release | |
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0 | |
with: | |
generate_release_notes: true | |
tag_name: v${{ needs.metadata.outputs.version }} | |
draft: true | |
files: pixi-pack-* |