Release #202
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: Release | |
on: | |
workflow_run: | |
workflows: ["Cargo Build & Test"] | |
branches: [main] | |
types: | |
- completed | |
push: | |
tags: | |
- "v*.*.*" | |
permissions: | |
contents: write | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
release: | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
name: Release - ${{ matrix.platform.target }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
arch: x64 | |
os_name: windows | |
bins: cross | |
build: cross | |
- os: windows-latest | |
target: i686-pc-windows-msvc | |
arch: x86 | |
os_name: windows | |
bins: cross | |
build: cross | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
arch: arm64 | |
os_name: windows | |
bins: cross | |
build: cross | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
arch: x64 | |
os_name: linux | |
bins: cargo-deb, cargo-zigbuild | |
build: cargo-zigbuild | |
- os: ubuntu-latest | |
target: i686-unknown-linux-gnu | |
arch: x86 | |
os_name: linux | |
bins: cargo-deb, cargo-zigbuild | |
build: cargo-zigbuild | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
arch: arm64 | |
os_name: linux | |
bins: cargo-deb, cargo-zigbuild | |
build: cargo-zigbuild | |
- os: ubuntu-latest | |
target: armv7-unknown-linux-gnueabihf | |
arch: armv7 | |
os_name: linux | |
bins: cargo-deb, cargo-zigbuild | |
build: cargo-zigbuild | |
- os: ubuntu-latest | |
target: x86_64-unknown-freebsd | |
arch: x64 | |
os_name: freebsd | |
bins: cross | |
build: cross | |
- os: ubuntu-latest | |
target: i686-unknown-freebsd | |
arch: x86 | |
os_name: freebsd | |
bins: cross | |
build: cross | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
arch: x64 | |
os_name: macos | |
bins: cargo-zigbuild | |
build: cargo-zigbuild | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
arch: arm64 | |
os_name: macos | |
bins: cargo-zigbuild | |
build: cargo-zigbuild | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Setup Zig | |
uses: goto-bus-stop/setup-zig@v2 | |
if: ${{ matrix.platform.build == 'cargo-zigbuild' }} | |
- uses: moonrepo/setup-rust@v1 | |
with: | |
targets: ${{ matrix.platform.target }} | |
bins: ${{ matrix.platform.bins }} | |
cache: false | |
- name: Build binary | |
run: ${{ matrix.platform.build }} build --target ${{ matrix.platform.target }} --release --locked | |
- name: Create Deb package | |
if: ${{ matrix.platform.os_name == 'linux' }} | |
run: cargo deb --target ${{ matrix.platform.target }} --no-build --no-strip | |
- name: Rename binary | |
id: rename_binary | |
shell: pwsh | |
run: | | |
$bin = if ($env:RUNNER_OS -eq 'Windows') { "komac.exe" } else { "komac" } | |
$newName = "KomacPortable" | |
if ($env:RUNNER_OS -ne 'Windows') { | |
$newName += "-${{ matrix.platform.os_name }}" | |
} | |
if ($env:GITHUB_EVENT_NAME -eq 'workflow_run') { | |
$newName += "-nightly" | |
} | |
$newName += "-${{ matrix.platform.arch }}" | |
if ($env:RUNNER_OS -eq 'Windows') { | |
$newName += ".exe" | |
} | |
Rename-Item -Path "target/${{ matrix.platform.target }}/release/$bin" -NewName "$newName" | |
"name=$newName" >> $env:GITHUB_OUTPUT | |
- name: Create Tar archive | |
if: ${{ matrix.platform.os != 'windows-latest' }} | |
run: | | |
tar -czvf ${{ steps.rename_binary.outputs.name }}.tar.gz -C target/${{ matrix.platform.target }}/release ${{ steps.rename_binary.outputs.name }} | |
rm target/${{ matrix.platform.target }}/release/${{ steps.rename_binary.outputs.name }} | |
- name: Create Inno Installer | |
if: ${{ matrix.platform.os == 'windows-latest' }} | |
shell: pwsh | |
run: | | |
$input = "../target/${{ matrix.platform.target }}/release/${{ steps.rename_binary.outputs.name }}" | |
iscc.exe assets/installer.iss ` | |
/DInputExecutable=$input ` | |
/DArchitecture=${{ matrix.platform.arch }} ` | |
/F$("${{ steps.rename_binary.outputs.name }}".Replace("Portable", "Setup").TrimEnd(".exe")) | |
- name: Compute SHA256 checksum | |
shell: pwsh | |
run: | | |
Get-Item -ErrorAction SilentlyContinue -Path "${{ steps.rename_binary.outputs.name }}.tar.gz","assets/Output/*","target/${{ matrix.platform.target }}/release/*","target/${{ matrix.platform.target }}/debian/*" -Include "KomacPortable*","KomacSetup*","komac*.deb" | ForEach-Object { | |
$FileHash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash.ToLower() | |
New-Item -Force -ItemType File -Path $_.DirectoryName -Name "$($_.Name).sha256" -Value "$FileHash *$($_.Name)`n" | |
} | |
- name: Set Release variables | |
id: set_release_vars | |
shell: pwsh | |
run: | | |
if ($env:GITHUB_EVENT_NAME -eq 'workflow_run') { | |
"name=Nightly release" >> $env:GITHUB_OUTPUT | |
"tag_name=nightly" >> $env:GITHUB_OUTPUT | |
"prerelease=true" >> $env:GITHUB_OUTPUT | |
"generate_release_notes=false" >> $env:GITHUB_OUTPUT | |
} else { | |
"name=$env:GITHUB_REF_NAME" >> $env:GITHUB_OUTPUT | |
"tag_name=$env:GITHUB_REF" >> $env:GITHUB_OUTPUT | |
"prerelease=false" >> $env:GITHUB_OUTPUT | |
"generate_release_notes=true" >> $env:GITHUB_OUTPUT | |
} | |
- name: Release binaries | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ steps.set_release_vars.outputs.name }} | |
tag_name: ${{ steps.set_release_vars.outputs.tag_name }} | |
prerelease: ${{ steps.set_release_vars.outputs.prerelease }} | |
generate_release_notes: ${{ steps.set_release_vars.outputs.generate_release_notes }} | |
files: | | |
target/${{ matrix.platform.target }}/release/${{ steps.rename_binary.outputs.name }} | |
target/${{ matrix.platform.target }}/release/${{ steps.rename_binary.outputs.name }}.sha256 | |
target/${{ matrix.platform.target }}/debian/*.deb | |
target/${{ matrix.platform.target }}/debian/*.sha256 | |
${{ steps.rename_binary.outputs.name }}.tar.gz | |
${{ steps.rename_binary.outputs.name }}.tar.gz.sha256 | |
assets/Output/* |