Docker / publish (push) Canceled after 0s
Release / crates-io (push) Canceled after 0s
Release / release (macos-14, aarch64-apple-darwin) (push) Canceled after 0s
Release / release (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Canceled after 0s
Release / release (windows-latest, x86_64-pc-windows-msvc) (push) Canceled after 0s
`cargo fmt --all -- --check` and `cargo clippy --all-targets -- -D warnings` are
CI gates and both were failing on this release's code.
- rustfmt across the files touched by the release
- `.split('/').last()` walks the whole iterator on a DoubleEndedIterator; use
`.next_back()` (4 sites in the setup/featured + delete handlers)
- `set_progress` had two identical branches; the intent is "take the first
reading, then only move forward", which is one condition
release.yml published unconditionally on a version tag, so a version already on
crates.io (released by hand, or a re-run of the job) failed the workflow — a
version can never be re-uploaded. It now checks the registry and skips instead.
81 lines
2.9 KiB
YAML
81 lines
2.9 KiB
YAML
name: Release
|
|
|
|
# Triggered when a version tag is pushed, e.g. `git tag v0.1.0 && git push --tags`.
|
|
# Publishes the crate to crates.io and creates a GitHub Release with prebuilt binaries.
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
# --- publish to crates.io -------------------------------------------------
|
|
crates-io:
|
|
runs-on: ubuntu-latest
|
|
# Requires a CARGO_REGISTRY_TOKEN repo secret (Settings → Secrets → Actions).
|
|
env:
|
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
# Skip when this version is already on crates.io — a version can never be
|
|
# re-uploaded, so publishing one that exists (released by hand, or a re-run
|
|
# of this job) is a guaranteed failure rather than a real problem.
|
|
- name: Publish to crates.io
|
|
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
|
|
run: |
|
|
name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
|
|
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
|
|
if curl -sf -H 'User-Agent: cortiq-gateway-release' \
|
|
"https://crates.io/api/v1/crates/$name/$version" >/dev/null; then
|
|
echo "$name $version is already published — skipping"
|
|
else
|
|
cargo publish
|
|
fi
|
|
|
|
# --- prebuilt binaries + GitHub Release -----------------------------------
|
|
release:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
- os: macos-14
|
|
target: aarch64-apple-darwin
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Build
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
- name: Package
|
|
shell: bash
|
|
run: |
|
|
bin=cortiq-gateway
|
|
[ "${{ runner.os }}" = "Windows" ] && bin=cortiq-gateway.exe
|
|
staging="cortiq-gateway-${{ github.ref_name }}-${{ matrix.target }}"
|
|
mkdir "$staging"
|
|
cp "target/${{ matrix.target }}/release/$bin" "$staging"/
|
|
cp README.md LICENSE config/gateway.example.toml "$staging"/
|
|
if [ "${{ runner.os }}" = "Windows" ]; then
|
|
7z a "$staging.zip" "$staging" >/dev/null
|
|
echo "ASSET=$staging.zip" >> "$GITHUB_ENV"
|
|
else
|
|
tar czf "$staging.tar.gz" "$staging"
|
|
echo "ASSET=$staging.tar.gz" >> "$GITHUB_ENV"
|
|
fi
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: ${{ env.ASSET }}
|
|
generate_release_notes: true
|