update workflow #3
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 and Release | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
packages: write | |
attestations: write | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
name: Build ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
artifact_name: french-names-extractor | |
asset_name: insee-names-extractor-linux-amd64 | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
artifact_name: french-names-extractor.exe | |
asset_name: insee-names-extractor-windows-amd64.exe | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
artifact_name: french-names-extractor | |
asset_name: insee-names-extractor-macos-x86_64 | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
artifact_name: french-names-extractor | |
asset_name: insee-names-extractor-macos-arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
# on ubuntu install musl-dev and musl-tools | |
- name: Install musl | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y musl-dev musl-tools | |
- name: Install Rust | |
uses: crusty-pie/toolchain@main | |
with: | |
targets: ${{ matrix.target }} | |
- name: Build | |
continue-on-error: true | |
run: cargo build --verbose --release --target ${{ matrix.target }} | |
- name: Rename binary | |
continue-on-error: true | |
shell: bash | |
run: | | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }} | |
else | |
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }} | |
fi | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.asset_name }} | |
path: ${{ matrix.asset_name }} | |
retention-days: 5 | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
insee-names-extractor-linux-amd64 | |
insee-names-extractor-windows-amd64.exe | |
insee-names-extractor-macos-x86_64 | |
insee-names-extractor-macos-arm64 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |