Release #731
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 | |
release: | |
types: [ released ] | |
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 | |
inno_arch: x64 | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
inno_arch: arm64 | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
bins: cargo-deb, cargo-generate-rpm | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
bins: cross, cargo-deb, cargo-generate-rpm | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- uses: moonrepo/setup-rust@v1 | |
with: | |
targets: ${{ matrix.platform.target }} | |
bins: ${{ matrix.platform.bins }} | |
cache: false | |
- name: Build binary | |
shell: pwsh | |
run: | | |
$tool = if ("${{ matrix.platform.bins }}".Contains("cross")) { "cross" } else { "cargo" } | |
& $tool build --target ${{ matrix.platform.target }} --release --locked | |
- name: Create Deb package | |
if: contains(matrix.platform.bins, 'cargo-deb') | |
shell: pwsh | |
run: | | |
$nightly = if ($env:GITHUB_EVENT_NAME -eq 'workflow_run') { "--deb-version=2.nightly" } else { "" } | |
cargo deb --target ${{ matrix.platform.target }} --no-build --no-strip $nightly | |
- name: Create RPM package | |
if: contains(matrix.platform.bins, 'cargo-generate-rpm') | |
shell: pwsh | |
run: | | |
if ($env:GITHUB_EVENT_NAME -eq 'workflow_run') { | |
cargo generate-rpm --target ${{ matrix.platform.target }} --set-metadata='version="nightly"' | |
} else { | |
cargo generate-rpm --target ${{ matrix.platform.target }} | |
} | |
- name: Rename binary | |
id: rename_binary | |
shell: pwsh | |
run: | | |
$bin = if ($env:RUNNER_OS -eq 'Windows') { "komac.exe" } else { "komac" } | |
$newName = "komac" | |
if ($env:GITHUB_EVENT_NAME -eq 'workflow_run') { | |
$newName += "-nightly" | |
} else { | |
$newName += "-$($env:GITHUB_REF_NAME.TrimStart('v'))" | |
} | |
$newName += "-${{ matrix.platform.target }}" | |
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: ${{ runner.os != 'Windows' }} | |
run: | | |
tar -czvf ${{ steps.rename_binary.outputs.name }}.tar.gz -C target/${{ matrix.platform.target }}/release komac | |
rm target/${{ matrix.platform.target }}/release/komac | |
- name: Create Inno Installer | |
if: ${{ runner.os == 'Windows' }} | |
shell: pwsh | |
run: | | |
$input = "../target/${{ matrix.platform.target }}/release/${{ steps.rename_binary.outputs.name }}" | |
iscc.exe assets/installer.iss ` | |
/DInputExecutable=$input ` | |
/DArchitecture=${{ matrix.platform.inno_arch }} ` | |
/F$("${{ steps.rename_binary.outputs.name }}".Replace("komac", "komac-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/*","target/${{ matrix.platform.target }}/generate-rpm/*" -Include "komac-*", "komac*.deb", "komac*.rpm" | 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 { | |
"prerelease=false" >> $env:GITHUB_OUTPUT | |
"generate_release_notes=true" >> $env:GITHUB_OUTPUT | |
} | |
- name: Release binaries | |
uses: softprops/action-gh-release@v2 | |
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 | |
target/${{ matrix.platform.target }}/generate-rpm/*.rpm | |
target/${{ matrix.platform.target }}/generate-rpm/*.sha256 | |
${{ steps.rename_binary.outputs.name }}.tar.gz | |
${{ steps.rename_binary.outputs.name }}.tar.gz.sha256 | |
assets/Output/* | |
publish-winget: | |
needs: release | |
if: ${{ github.event_name != 'workflow_run' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: vedantmgoyal9/winget-releaser@main | |
with: | |
identifier: RussellBanks.Komac | |
installers-regex: 'komac-setup.*\.exe$' | |
token: ${{ secrets.WINGET_TOKEN }} | |
publish-homebrew-tap: | |
needs: release | |
if: ${{ github.event_name != 'workflow_run' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger update formula workflow (homebrew-tap) | |
run: gh workflow run komac.yml -f version=$($env:GITHUB_REF_NAME.TrimStart('v')) -R russellbanks/homebrew-tap | |
env: | |
GH_TOKEN: ${{ secrets.WINGET_TOKEN }} | |
shell: pwsh | |
upload-virus-total: | |
needs: release | |
if: ${{ github.event_name != 'workflow_run' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: VirusTotal Scan | |
uses: crazy-max/ghaction-virustotal@v4 | |
with: | |
vt_api_key: ${{ secrets.VT_API_KEY }} | |
request_rate: 4 | |
files: | | |
.exe$ | |
.deb$ | |
.rpm$ | |
.tar.gz$ | |
publish-crates-io: | |
needs: release | |
if: ${{ github.event_name != 'workflow_run' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- uses: moonrepo/setup-rust@v1 | |
with: | |
cache: false | |
- name: Publish to crates.io | |
run: cargo publish | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |