1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# ------------------------------------------------------------------------------
# release.yml
# Build release binaries for all Verilator CI platforms and publish GitHub
# Releases when a version tag is pushed.
#
# Trigger manually via "Run workflow" on any branch to test without releasing.
#
# SPDX-FileCopyrightText: Hudson River Trading
# SPDX-License-Identifier: MIT
# ------------------------------------------------------------------------------
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write # needed to create GitHub Releases
jobs:
build:
name: Build | ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
archive: tar.gz
- name: macos-arm64
runner: macos-15
target: aarch64-apple-darwin
archive: tar.gz
- name: windows-x86_64
runner: windows-2025
target: x86_64-pc-windows-msvc
archive: zip
steps:
- uses: actions/checkout@v4
- name: Verify tag matches Cargo.toml version
if: github.ref_type == 'tag'
shell: bash
run: |
cargo_version=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')
tag_version="${{ github.ref_name }}"
tag_version="${tag_version#v}"
if [[ "$cargo_version" != "$tag_version" ]]; then
echo "::error::Tag version ($tag_version) does not match Cargo.toml version ($cargo_version)"
exit 1
fi
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Determine version tag
id: version
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
else
echo "tag=dev-${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"
fi
- name: Package (unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
dir="wavetools-${{ steps.version.outputs.tag }}-${{ matrix.name }}"
mkdir "$dir"
cp target/${{ matrix.target }}/release/wavecat "$dir/"
cp target/${{ matrix.target }}/release/wavediff "$dir/"
tar czf "${dir}.tar.gz" "$dir"
- name: Package (windows)
if: matrix.archive == 'zip'
shell: bash
run: |
dir="wavetools-${{ steps.version.outputs.tag }}-${{ matrix.name }}"
mkdir "$dir"
cp target/${{ matrix.target }}/release/wavecat.exe "$dir/"
cp target/${{ matrix.target }}/release/wavediff.exe "$dir/"
7z a "${dir}.zip" "$dir"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: wavetools-${{ matrix.name }}
path: wavetools-*.${{ matrix.archive }}
release:
name: Publish GitHub Release
if: github.ref_type == 'tag'
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
wavetools-*.tar.gz
wavetools-*.zip
publish:
name: Publish to crates.io
if: github.ref_type == 'tag'
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify tag is on main
run: |
if ! git merge-base --is-ancestor "${{ github.sha }}" origin/main; then
echo "::error::Tag is not on the main branch -- skipping publish"
exit 1
fi
- uses: dtolnay/rust-toolchain@stable
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}