v2.0.0 #9
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 and release | |
on: | |
workflow_dispatch: | |
release: | |
types: [ created ] | |
permissions: | |
contents: write | |
jobs: | |
publish_crates_io: | |
name: Publish to crates.io | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Login with cargo | |
run: cargo login ${{ secrets.CRATES_IO_TOKEN }} | |
- name: Publish package | |
run: cargo publish | |
publish: | |
name: ${{ matrix.platform.os_name }} with Rust ${{ matrix.toolchain }} | |
runs-on: ${{ matrix.platform.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- os_name: Linux-aarch64 | |
os: ubuntu-20.04 | |
target: aarch64-unknown-linux-musl | |
bin: envfetch-linux-arm64 | |
- os_name: Linux-x86_64 | |
os: ubuntu-20.04 | |
target: x86_64-unknown-linux-gnu | |
bin: envfetch-linux-amd64 | |
- os_name: Windows-x86_64 | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
bin: envfetch-windows-amd64.exe | |
- os_name: macOS-x86_64 | |
os: macOS-latest | |
target: x86_64-apple-darwin | |
bin: envfetch-darwin-amd64 | |
- os_name: macOS-aarch64 | |
os: macOS-latest | |
target: aarch64-apple-darwin | |
bin: envfetch-darwin-arm64 | |
toolchain: | |
- stable | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build binary | |
uses: houseabsolute/actions-rust-cross@v0 | |
with: | |
command: "build" | |
target: ${{ matrix.platform.target }} | |
toolchain: ${{ matrix.toolchain }} | |
args: "--locked --release" | |
strip: true | |
- name: Rename binary (linux and macos) | |
run: mv target/${{ matrix.platform.target }}/release/envfetch target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | |
if: matrix.platform.os_name != 'Windows-x86_64' | |
- name: Generate ZIP and checksum for it (Windows) | |
run: | | |
cd target/${{ matrix.platform.target }}/release | |
tar.exe -a -c -f envfetch-windows-amd64.zip envfetch.exe | |
shasum -a 256 envfetch-windows-amd64.zip | cut -d ' ' -f 1 > envfetch-windows-amd64.zip.sha256 | |
if: matrix.platform.os_name == 'Windows-x86_64' | |
- name: Rename binary (windows) | |
run: mv target/${{ matrix.platform.target }}/release/envfetch.exe target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | |
if: matrix.platform.os_name == 'Windows-x86_64' | |
- name: Generate Debian package | |
run: cargo install cargo-deb && cargo deb --output target/debian/envfetch-debian.deb | |
if: matrix.platform.os_name == 'Linux-x86_64' | |
- name: Generate SHA-256 for Debian package | |
run: shasum -a 256 target/debian/envfetch-debian.deb | cut -d ' ' -f 1 > target/debian/envfetch-debian.deb.sha256 | |
if: matrix.platform.os_name == 'Linux-x86_64' | |
- name: Generate SHA-256 | |
run: shasum -a 256 target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | cut -d ' ' -f 1 > target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.sha256 | |
- name: Release binary and SHA-256 checksum to GitHub | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | |
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.sha256 | |
- name: Release Debian package and SHA-256 checksum to GitHub | |
uses: softprops/action-gh-release@v1 | |
if: matrix.platform.os_name == 'Linux-x86_64' | |
with: | |
files: | | |
target/debian/envfetch-debian.deb | |
target/debian/envfetch-debian.deb.sha256 | |
- name: Release Windows archive and checksum of it to GitHub | |
uses: softprops/action-gh-release@v1 | |
if: matrix.platform.os_name == 'Windows-x86_64' | |
with: | |
files: | | |
target/${{ matrix.platform.target }}/release/envfetch-windows-amd64.zip | |
target/${{ matrix.platform.target }}/release/envfetch-windows-amd64.zip.sha256 |