name: Release
on:
push:
tags:
- 'v*'
env:
RUST_BACKTRACE: 1
jobs:
build-matrix:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-11-arm
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 with:
persist-credentials: false
- name: Setup rust toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 with:
channel: stable
bins: cargo-zigbuild
- name: Build
run: |
cargo build --release
shell: bash
- name: Create package (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p d2o-${{ matrix.target }}
cp target/release/d2o d2o-${{ matrix.target }}/
cp -r out/man out/completions d2o-${{ matrix.target }}/
cp README.md LICENSE d2o-${{ matrix.target }}/
tar -czf d2o-${{ matrix.target }}.tar.gz d2o-${{ matrix.target }}/
shell: bash
- name: Create package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Path "d2o-${{ matrix.target }}" -Force
Copy-Item "target/release/d2o.exe" "d2o-${{ matrix.target }}/"
Copy-Item "out/completions", "out/man" "d2o-${{ matrix.target }}/" -Recurse -Force
Copy-Item "README.md", "LICENSE" "d2o-${{ matrix.target }}/"
Compress-Archive -Path "d2o-${{ matrix.target }}" -DestinationPath "d2o-${{ matrix.target }}.zip" -Force
- name: Upload artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 with:
name: d2o-${{ matrix.target }}
path: |
d2o-${{ matrix.target }}.tar.gz
d2o-${{ matrix.target }}.zip
create-release:
name: Create Release
needs: build-matrix
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 with:
persist-credentials: false
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release-assets
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} release-assets/ \;
ls -lh release-assets/
- name: Install node
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f with:
node-version: latest
- name: Generate Changelog
run: |
npx changelogithub@latest --output changelog.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
run: |
gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 \
&& gh release upload "$GITHUB_REF_NAME" release-assets/* --clobber \
|| gh release create "$GITHUB_REF_NAME" --notes-file changelog.md release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crates-io:
name: Publish to crates.io
needs: create-release
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 with:
persist-credentials: false
- uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 - uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec id: auth
- name: Publish
run: cargo publish --token ${{ steps.auth.outputs.token }} --no-verify