Skip to content

Commit

Permalink
CI: Early sketches of a CI-based release pipeline
Browse files Browse the repository at this point in the history
- large restructuring of the Justfile release commands
- sketch of a release action
  • Loading branch information
kleinesfilmroellchen committed Oct 1, 2024
1 parent b92b269 commit fb8ab01
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 22 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
on:
release:
types: [created]

jobs:
release:
name: Release build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
runner: windows-latest
archive: zip
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
archive: tar.xz
- target: x86_64-apple-darwin
runner: macos-latest
archive: tar.xz
- target: aarch64-apple-darwin
runner: macos-latest
archive: tar.xz
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Install just
uses: extractions/setup-just@v2

- name: Install nextest (Linux)
if: ${{ matrix.runner == 'ubuntu-latest' }}
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Install nextest (macOS)
if: ${{ matrix.runner == 'macos-latest' }}
run: curl -LsSf https://get.nexte.st/latest/mac | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Install nextest (Windows)
if: ${{ matrix.runner == 'windows-latest' }}
run: |
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru
Invoke-WebRequest -OutFile $tmp https://get.nexte.st/latest/windows
$outputDir = if ($Env:CARGO_HOME) { Join-Path $Env:CARGO_HOME "bin" } else { "~/.cargo/bin" }
$tmp | Expand-Archive -DestinationPath $outputDir -Force
$tmp | Remove-Item
- name: Build release artifacts
run: just release ${{ github.ref }} ${{ matrix.target }}

- name: Upload release asset
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: spcasm-${{ github.ref }}-${{ matrix.target }}.${{ matrix.archive }}
48 changes: 26 additions & 22 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,39 @@ website url="/":
cp -rT doc/book/html site/doc
cp -rT target/doc site/doc/api

# Create a new spcasm release from a Windows machine
[windows]
release version: release-build-common && (release-finalize-common version)
wsl just release-build-common

# Create a new spcasm release from a Unix machine
[unix]
release version: release-build-common && (release-finalize-common version)
# Create a new spcasm release for the specified target.
release version target: release-build-common target && (release-finalize version target)

release-build-common: test check
cargo build -q --profile=spcasm-release
# Common build steps for all targets.
release-build-common target:
cargo nextest run --target {{target}}
cargo build --workspace -q --profile=spcasm-release --target {{target}}

release-finalize-common version:
# Specific finalization steps for Windows
[windows]
release-finalize version target:
mkdir 'spcasm-{{version}}'
cp target/spcasm-release/spcasm.exe 'spcasm-{{version}}'
cp target/spcasm-release/spcasm 'spcasm-{{version}}'
cp target/spcasm-release/brr.exe 'spcasm-{{version}}'
cp target/spcasm-release/brr 'spcasm-{{version}}'
Copy-Item target/spcasm-release/spcasm.exe 'spcasm-{{version}}'
Copy-Item target/spcasm-release/brr.exe 'spcasm-{{version}}'
@echo '======================================================================='
@echo 'spcasm and brr version(s)'
wsl './spcasm-{{version}}/spcasm' --version
./spcasm-{{version}}/spcasm.exe --version
wsl './spcasm-{{version}}/brr' --version
./spcasm-{{version}}/brr.exe --version
cd doc && mdbook build
wsl -e cp -rT include 'spcasm-{{version}}/include'
cd spcasm-{{version}} && zip spcasm-{{version}}.zip '*' 'include/*' -x spcasm brr
wsl -e tar -caz --exclude '*.exe' --exclude '*.zip' -f spcasm-{{version}}.tar.xz -C spcasm-{{version}} .
mv spcasm-{{version}}.tar.xz spcasm-{{version}}
Copy-Item -Recurse include 'spcasm-{{version}}'
cd spcasm-{{version}} && zip spcasm-{{version}}-{{target}}.zip '*' 'include/*'

# Specific finalization steps for Unix
[unix]
release-finalize version target:
cp target/spcasm-release/spcasm 'spcasm-{{version}}'
cp target/spcasm-release/brr 'spcasm-{{version}}'
@echo '======================================================================='
@echo 'spcasm and brr version(s)'
'./spcasm-{{version}}/spcasm' --version
'./spcasm-{{version}}/brr' --version
cp -rT include 'spcasm-{{version}}/include'
tar caz -f spcasm-{{version}}-{{target}}.tar.xz -C spcasm-{{version}} .


clean:
cargo clean -r

0 comments on commit fb8ab01

Please sign in to comment.