name: Release
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
BINARY_NAME: copernicus_viewer
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libxkbcommon-dev \
libgl1-mesa-dev \
libwayland-dev \
libxrandr-dev \
libxinerama-dev \
libxcursor-dev \
libxi-dev \
pkg-config \
libnetcdf-dev \
cmake
- name: Run tests (Zarr-only)
run: cargo test --locked --no-default-features --features dialog-portal
- name: Run tests (SAFE, static NetCDF)
run: cargo test --locked --no-default-features --features safe,dialog-portal,netcdf-static
publish-crates:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libxkbcommon-dev \
libgl1-mesa-dev \
libwayland-dev \
libxrandr-dev \
libxinerama-dev \
libxcursor-dev \
libxi-dev \
pkg-config \
libnetcdf-dev \
cmake
- name: Publish to crates.io
run: cargo publish --locked --token "${{ secrets.CARGO_REGISTRY_TOKEN }}"
build:
needs: test
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
safe: false
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
safe: true
- runner: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
safe: false
- runner: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
safe: true
- runner: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
safe: false
- runner: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
safe: true
- runner: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
safe: false
- runner: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
safe: true
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}-safe-${{ matrix.safe }}
- name: Install Linux GUI build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libxkbcommon-dev \
libgl1-mesa-dev \
libwayland-dev \
libxrandr-dev \
libxinerama-dev \
libxcursor-dev \
libxi-dev \
pkg-config \
cmake
- name: Build release binary (Zarr-only)
if: matrix.safe == false
run: cargo build --locked --release --target ${{ matrix.target }} --no-default-features --features dialog-portal
- name: Build release binary (SAFE, static NetCDF)
if: matrix.safe == true
run: cargo build --locked --release --target ${{ matrix.target }} --no-default-features --features safe,dialog-portal,netcdf-static
- name: Package archive (Unix, Zarr-only)
if: matrix.archive == 'tar.gz' && matrix.safe == false
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
ARCHIVE="${RUNNER_TEMP}/${{ env.BINARY_NAME }}-${VERSION}-${{ matrix.target }}.tar.gz"
tar czf "${ARCHIVE}" -C "target/${{ matrix.target }}/release" "${{ env.BINARY_NAME }}"
- name: Package archive (Unix, SAFE)
if: matrix.archive == 'tar.gz' && matrix.safe == true
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
ARCHIVE="${RUNNER_TEMP}/${{ env.BINARY_NAME }}-${VERSION}-${{ matrix.target }}-safe.tar.gz"
tar czf "${ARCHIVE}" -C "target/${{ matrix.target }}/release" "${{ env.BINARY_NAME }}"
- name: Package archive (Windows, Zarr-only)
if: matrix.archive == 'zip' && matrix.safe == false
shell: pwsh
run: |
$Version = $env:GITHUB_REF_NAME.Substring(1)
$Archive = Join-Path $env:RUNNER_TEMP "${{ env.BINARY_NAME }}-${Version}-${{ matrix.target }}.zip"
Compress-Archive `
-Path "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" `
-DestinationPath $Archive
- name: Package archive (Windows, SAFE)
if: matrix.archive == 'zip' && matrix.safe == true
shell: pwsh
run: |
$Version = $env:GITHUB_REF_NAME.Substring(1)
$Archive = Join-Path $env:RUNNER_TEMP "${{ env.BINARY_NAME }}-${Version}-${{ matrix.target }}-safe.zip"
Compress-Archive `
-Path "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" `
-DestinationPath $Archive
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}-safe-${{ matrix.safe }}
path: ${{ runner.temp }}/${{ env.BINARY_NAME }}-*
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Generate release notes
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: --latest --strip header --strip footer
github_token: ${{ secrets.GITHUB_TOKEN }}
env:
OUTPUT: RELEASE_NOTES.md
- name: Update CHANGELOG.md
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
github_token: ${{ secrets.GITHUB_TOKEN }}
env:
OUTPUT: CHANGELOG.md
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Write checksums
shell: bash
run: |
cd dist
sha256sum ${{ env.BINARY_NAME }}-* > SHA256SUMS.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: RELEASE_NOTES.md
files: |
dist/${{ env.BINARY_NAME }}-*
dist/SHA256SUMS.txt
- name: Commit changelog
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git diff --staged --quiet || git commit -m "chore: update CHANGELOG.md for ${GITHUB_REF_NAME}"
git push origin main