Skip to content

Commit

Permalink
chore(ci): use updated deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
tversteeg committed Oct 21, 2023
1 parent fd0c5b6 commit e92e9ef
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 116 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

permissions:
pull-requests: write
contents: write

on:
push:
branches:
- master

jobs:
release-plz:
name: Release PR
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
126 changes: 10 additions & 116 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ on:
paths-ignore:
- "docs/**"
- "**.md"
pull_request:
paths-ignore:
- "docs/**"
- "**.md"

jobs:
# Check for formatting
Expand All @@ -30,9 +26,9 @@ jobs:
command: fmt
args: --all -- --check

# Run compile check on Linux, macOS, and Windows
compile:
name: Compile
# Run test check on Linux, macOS, and Windows
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
Expand All @@ -48,122 +44,20 @@ jobs:
toolchain: stable

# Cache the built dependencies
- uses: Swatinem/rust-cache@v2.7.1
- uses: Swatinem/rust-cache@v2.7.0
with:
save-if: ${{ github.event_name == 'push' }}

# Install cargo-hack
- uses: taiki-e/install-action@cargo-hack

# Compile all feature combinations on the target platform
- name: Compile
run: cargo hack --feature-powerset check

# Build sources for every OS
desktop:
if: startsWith(github.ref, 'refs/tags/')
name: Desktop Build
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: sprite-x86_64-unknown-linux-gnu
- target: x86_64-apple-darwin
os: macOS-latest
name: sprite-x86_64-apple-darwin
- target: x86_64-pc-windows-msvc
os: windows-latest
name: sprite-x86_64-pc-windows-msvc.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}

- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y libx11-dev libxi-dev libgl1-mesa-dev gcc-mingw-w64

- name: Build target
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}

- name: Prepare build artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip sprite.exe
mv sprite.exe ../../../${{ matrix.name }}
cd -
- name: Prepare build artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip sprite
mv sprite ../../../${{ matrix.name }}
cd -
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}

# Create GitHub release with Rust build targets and release notes
github_release:
if: startsWith(github.ref, 'refs/tags/')
name: GitHub Release
needs: desktop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# These can be squashed when https://github.com/actions/download-artifact/issues/6 is closed
- name: Download releases from 'dekstop'
uses: actions/download-artifact@v3
with:
name: sprite-x86_64-unknown-linux-gnu
path: .
- name: Download releases from 'desktop'
uses: actions/download-artifact@v3
with:
name: sprite-x86_64-apple-darwin
path: .
- name: Download releases from 'desktop'
uses: actions/download-artifact@v3
with:
name: sprite-x86_64-pc-windows-msvc.exe
path: .

- name: Generate checksums
run: for file in sprite-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done

- name: Create GitHub release ${{ matrix.target }}
uses: softprops/action-gh-release@v1
with:
files: |
sprite-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Test all feature combinations on the target platform
- name: Test
run: cargo hack --feature-powerset test

# Build the WASM target & push it to GitHub pages
wasm:
name: WASM build
name: WASM test & build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -175,13 +69,13 @@ jobs:
targets: wasm32-unknown-unknown

# Cache the built dependencies
- uses: Swatinem/rust-cache@v2.7.1
- uses: Swatinem/rust-cache@v2.7.0
with:
save-if: ${{ github.event_name == 'push' }}

# Build the WASM
- name: Build
run: cargo run --package run-wasm -- --bin sprite --no-default-features --release --build-only
run: cargo run --package run-wasm -- --bin sprite --release --build-only

# Deploy to GitHub pages
- name: Deploy to GitHub Pages
Expand Down
24 changes: 24 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[workspace]
# Disable the changelog for all packages
changelog_update = false

[[package]]
name = "sprite"
# Use the changelog for this package
changelog_update = true
changelog_path = "./CHANGELOG.md"

[[package]]
name = "sprite-gen"
# Use the changelog for this package
changelog_update = true
changelog_path = "./CHANGELOG.md"

# Ignore run-wasm
[[package]]
name = "run-wasm"
semver_check = false
changelog_update = false
git_tag_enable = false
git_release_enable = false
publish = false

0 comments on commit e92e9ef

Please sign in to comment.