code_work_spawner/.github/workflows/release.yaml

102 lines
2.8 KiB
YAML

name: release
on:
release:
types:
- published
pull_request:
paths:
- .github/workflows/release.yaml
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.target_os }}-${{ matrix.target_arch }}
runs-on: ${{ matrix.runs_on }}
strategy:
fail-fast: false
matrix:
include:
- runs_on: ubuntu-24.04
target_os: linux
target_arch: x64
ext: ''
- runs_on: ubuntu-24.04
target_os: linux
target_arch: arm64
ext: ''
- runs_on: macos-14
target_os: macos
target_arch: arm64
ext: ''
- runs_on: windows-2022
target_os: windows
target_arch: x64
ext: .exe
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
- name: Install dependencies
run: dart pub get
- name: Generate code
run: dart run build_runner build --delete-conflicting-outputs
- name: Build executable
shell: bash
run: |
mkdir -p dist
if [[ "${{ matrix.target_os }}" == "linux" ]]; then
dart compile exe bin/code_work_spawner.dart --target-os=linux --target-arch=${{ matrix.target_arch }} -o dist/code_work_spawner${{ matrix.ext }}
else
dart compile exe bin/code_work_spawner.dart -o dist/code_work_spawner${{ matrix.ext }}
fi
- name: Prepare release asset
shell: bash
run: |
mkdir -p release-assets
if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
version_tag="${GITHUB_REF_NAME}"
else
version_tag="${GITHUB_REF_NAME//\//-}"
fi
asset_name="code_work_spawner-${version_tag}-${{ matrix.target_os }}-${{ matrix.target_arch }}${{ matrix.ext }}"
cp "dist/code_work_spawner${{ matrix.ext }}" "release-assets/${asset_name}"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: code_work_spawner-${{ matrix.target_os }}-${{ matrix.target_arch }}
path: release-assets/*
if-no-files-found: error
publish:
name: Upload release assets
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: Generate checksums
run: |
cd release-assets
sha256sum * > SHA256SUMS.txt
- name: Upload assets to release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.ref_name }}" release-assets/* --clobber