diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 47e66ee..2e0a3ea 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,13 +4,16 @@ on: release: types: - published + pull_request: + paths: + - .github/workflows/release.yaml permissions: - contents: write + contents: read jobs: build: - name: Build ${{ matrix.target_os }}-${{ matrix.arch }} + name: Build ${{ matrix.target_os }}-${{ matrix.target_arch }} runs-on: ${{ matrix.runs_on }} strategy: fail-fast: false @@ -18,19 +21,19 @@ jobs: include: - runs_on: ubuntu-24.04 target_os: linux - arch: x64 + target_arch: x64 ext: '' - - runs_on: ubuntu-24.04-arm + - runs_on: ubuntu-24.04 target_os: linux - arch: arm64 + target_arch: arm64 ext: '' - runs_on: macos-14 target_os: macos - arch: arm64 + target_arch: arm64 ext: '' - runs_on: windows-2022 target_os: windows - arch: x64 + target_arch: x64 ext: .exe steps: @@ -45,26 +48,41 @@ jobs: run: dart run build_runner build --delete-conflicting-outputs - name: Build executable - run: dart compile exe bin/code_work_spawner.dart -o dist/code_work_spawner${{ matrix.ext }} + 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 - asset_name="code_work_spawner-${{ github.ref_name }}-${{ matrix.target_os }}-${{ matrix.arch }}${{ matrix.ext }}" + 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.arch }} + 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