name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
version:
runs-on: ubuntu-latest
outputs:
number: ${{ steps.read.outputs.number }}
steps:
- uses: actions/checkout@v4
- id: read
name: The tag and Cargo.toml agree
run: |
number=$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -1)
if [ "v$number" != "$GITHUB_REF_NAME" ]; then
echo "tag $GITHUB_REF_NAME does not match Cargo.toml $number" >&2
exit 1
fi
echo "number=$number" >> "$GITHUB_OUTPUT"
build:
needs: version
strategy:
matrix:
target: [x86_64-pc-windows-msvc, aarch64-pc-windows-msvc]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- run: cargo build --release --locked --target ${{ matrix.target }}
- name: Archive
shell: pwsh
run: |
$name = "baka-${{ needs.version.outputs.number }}-${{ matrix.target }}"
New-Item -ItemType Directory $name | Out-Null
Copy-Item target/${{ matrix.target }}/release/baka.exe, README.md, LICENSE $name
Compress-Archive -Path "$name/*" -DestinationPath "$name.zip"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: baka-*.zip
release:
needs: [version, build]
runs-on: ubuntu-latest
outputs:
x64: ${{ steps.sums.outputs.x64 }}
arm64: ${{ steps.sums.outputs.arm64 }}
steps:
- uses: actions/download-artifact@v4
with:
path: archives
merge-multiple: true
- id: sums
working-directory: archives
run: |
sha256sum *.zip | tee SHA256SUMS.txt
{
echo "x64=$(awk '/x86_64/ { print $1 }' SHA256SUMS.txt)"
echo "arm64=$(awk '/aarch64/ { print $1 }' SHA256SUMS.txt)"
} >> "$GITHUB_OUTPUT"
- name: Publish the release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" archives/* \
--repo "$GITHUB_REPOSITORY" \
--title "$GITHUB_REF_NAME" \
--generate-notes
crates:
needs: release
runs-on: ubuntu-latest
env:
TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- if: env.TOKEN != ''
run: cargo publish --locked --token "$TOKEN"
winget:
needs: [version, release]
runs-on: windows-latest
env:
TOKEN: ${{ secrets.WINGET_TOKEN }}
steps:
- uses: actions/checkout@v4
- if: env.TOKEN != ''
shell: bash
run: >
bash scripts/manifests.sh
"${{ needs.version.outputs.number }}"
"${{ needs.release.outputs.x64 }}"
"${{ needs.release.outputs.arm64 }}"
rendered
- name: Open the pull request against microsoft/winget-pkgs
if: env.TOKEN != ''
shell: pwsh
run: |
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
./wingetcreate.exe submit rendered/winget --token $env:TOKEN
scoop:
needs: [version, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- run: >
bash scripts/manifests.sh
"${{ needs.version.outputs.number }}"
"${{ needs.release.outputs.x64 }}"
"${{ needs.release.outputs.arm64 }}"
rendered
- name: Point the bucket at the new release
run: |
mkdir -p bucket
mv rendered/baka.json bucket/baka.json
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add bucket/baka.json
git diff --cached --quiet || git commit -m "Scoop manifest for $GITHUB_REF_NAME"
git push origin main