name: Release
on:
workflow_dispatch:
inputs:
type:
description: "version bump type"
default: "patch"
required: true
type: choice
options:
- patch
- minor
- major
prerelease:
description: "prerelease"
default: false
required: true
type: boolean
env:
CARGO_TERM_COLOR: always
jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{steps.tag.outputs.tag}}
steps:
- uses: actions/checkout@v4
- name: Config git
run: git config user.name github_actions && git config user.email nil
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: Install cargo-workspaces
run: cargo binstall cargo-workspaces
- name: BUMP!
run: cargo ws version ${{inputs.type}} --no-individual-tags -y --tag-prefix ""
- name: Export version
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
id: tag
make-release:
runs-on: ubuntu-latest
needs: bump
permissions:
contents: write
steps:
- name: Create release
id: create_release
uses: softprops/action-gh-release@v3.0.2
with:
tag_name: ${{ needs.bump.outputs.tag }}
prerelease: ${{ inputs.prerelease }}
draft: true
binary:
runs-on: ${{matrix.os}}
needs: [bump, make-release]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
filestub: linux
butler-tag: linux
filesuffix:
- os: macos-latest
filestub: macos
butler-tag: mac
filesuffix:
- os: windows-latest
filestub: windows
butler-tag: win
filesuffix: ".exe"
permissions:
contents: write
env:
INITIAL_BIN_PATH: ./target/release/starbloom${{matrix.filesuffix}}
BIN_PATH: ./target/release/starbloom_${{matrix.filestub}}${{matrix.filesuffix}}
steps:
- uses: actions/checkout@v4
- name: Get latest commit
run: git pull
- name: Build binary
run: cargo build --release
- name: Rename binary
run: mv ${{env.INITIAL_BIN_PATH}} ${{env.BIN_PATH}}
- name: Upload binary
uses: softprops/action-gh-release@v3.0.2
with:
tag_name: ${{ needs.bump.outputs.tag }}
files: ${{ env.BIN_PATH }}
draft: true
- name: Setup butler
uses: remarkablegames/setup-butler@v3
- name: Upload to itch.io
run: butler push ${{ env.BIN_PATH }} mrmcscreamypant/starbloom:${{ matrix.butler-tag }} --userversion ${{ needs.bump.outputs.tag }}
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
publish-release:
runs-on: ubuntu-latest
needs: [binary, bump]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install git-cliff
run: npm i -g git-cliff
- name: Write changelog
run: git-cliff -o CHANGELOG.md
- name: debug
run: cat ./CHANGELOG.md
- name: Read changelog
id: changelog
run: |
echo "changelog<<EOF" >> $GITHUB_OUTPUT
cat ./CHANGELOG.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Publish release
uses: softprops/action-gh-release@v3.0.2
with:
tag_name: ${{ needs.bump.outputs.tag }}
body: ${{steps.changelog.outputs.changelog}}
draft: false
web:
runs-on: ubuntu-latest
needs: bump
permissions:
contents: write
pages: write
steps:
- uses: actions/checkout@v4
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: Install trunk
run: cargo binstall trunk
- name: Add wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown
- name: Build
run: trunk build --release --features web
- name: Setup butler
uses: remarkablegames/setup-butler@v3
- name: Deploy to gh pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist
- name: Upload to itch.io
run: butler push dist mrmcscreamypant/starbloom:web --userversion ${{ needs.bump.outputs.tag }}
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
publish-cargo:
runs-on: ubuntu-latest
needs: bump
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Get latest commit
run: git pull
- name: Authenticate to crates.io
uses: rust-lang/crates-io-auth-action@v1.0.5
id: auth
- name: Publish to crates.io
run: cargo publish --workspace
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}