|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "release/**", "develop" ] |
| 6 | + tags: [ "samedec-*" ] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + RUST_BACKTRACE: 1 |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Linux builds, with Docker and qemu as required |
| 17 | + release_linux: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + env: |
| 21 | + # See <https://hub.docker.com/_/rust> for list of tags |
| 22 | + BUILD_RUST_TAG: 1.67.0 |
| 23 | + BUILD_OS_GNU: slim-buster |
| 24 | + BUILD_OS_MUSL: alpine |
| 25 | + |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + include: |
| 29 | + - docker: linux/amd64 |
| 30 | + os: slim-buster |
| 31 | + rust: x86_64-unknown-linux-gnu |
| 32 | + |
| 33 | + - docker: linux/amd64 |
| 34 | + os: alpine |
| 35 | + rust: x86_64-unknown-linux-musl |
| 36 | + |
| 37 | + - docker: linux/arm64 |
| 38 | + os: slim-buster |
| 39 | + rust: aarch64-unknown-linux-gnu |
| 40 | + |
| 41 | + - docker: linux/arm64 |
| 42 | + os: alpine |
| 43 | + rust: aarch64-unknown-linux-musl |
| 44 | + |
| 45 | + - docker: linux/arm/v7 |
| 46 | + os: slim-buster |
| 47 | + rust: armv7-unknown-linux-gnueabihf |
| 48 | + |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v3 |
| 51 | + |
| 52 | + - name: Workaround for https://github.com/rust-lang/cargo/issues/8719 |
| 53 | + run: | |
| 54 | + sudo mkdir -p /var/lib/docker |
| 55 | + sudo mount -t tmpfs -o size=10G none /var/lib/docker |
| 56 | + sudo systemctl restart docker |
| 57 | +
|
| 58 | + - name: Set up QEMU |
| 59 | + uses: docker/setup-qemu-action@v2 |
| 60 | + with: |
| 61 | + platforms: all |
| 62 | + |
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v1 |
| 65 | + |
| 66 | + - name: Prepare output directory |
| 67 | + run: | |
| 68 | + mkdir -m 700 -p "install/bin" |
| 69 | +
|
| 70 | + # Builds a special target in our Dockerfile which builds |
| 71 | + # an empty image containing only our Rust binary. This task |
| 72 | + # exports the file to |
| 73 | + # install/bin/samedec-x86_64-unknown-linux-gnu |
| 74 | + # and the like. |
| 75 | + - name: Build |
| 76 | + uses: docker/build-push-action@v3 |
| 77 | + with: |
| 78 | + context: . |
| 79 | + push: false |
| 80 | + load: false |
| 81 | + cache-from: type=gha,scope=${{ matrix.os }}_${{ matrix.rust }} |
| 82 | + cache-to: type=gha,mode=max,scope=${{ matrix.os }}_${{ matrix.rust }} |
| 83 | + tags: samedec:latest |
| 84 | + target: localfile |
| 85 | + build-args: | |
| 86 | + CARGO_BUILD_TARGET=${{ matrix.rust }} |
| 87 | + BUILD_OS_TAG=${{ matrix.os }} |
| 88 | + BUILD_RUST_TAG=${{ env.BUILD_RUST_TAG }} |
| 89 | + platforms: ${{ matrix.docker }} |
| 90 | + outputs: "type=local,dest=install/bin" |
| 91 | + |
| 92 | + - name: Copy artifact |
| 93 | + run: | |
| 94 | + cp install/bin/samedec install/bin/samedec-${{ matrix.rust }} |
| 95 | +
|
| 96 | + - name: Store artifact |
| 97 | + uses: actions/upload-artifact@v3 |
| 98 | + with: |
| 99 | + name: samedec-${{ matrix.rust }} |
| 100 | + path: install/bin/samedec-${{ matrix.rust }} |
| 101 | + retention-days: 3 |
| 102 | + |
| 103 | + - name: Upload tagged release |
| 104 | + uses: svenstaro/upload-release-action@v2 |
| 105 | + if: startsWith(github.ref, 'refs/tags/samedec-') |
| 106 | + with: |
| 107 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + file: install/bin/samedec-${{ matrix.rust }} |
| 109 | + overwrite: true |
| 110 | + |
| 111 | + - name: Update tag for nightly release |
| 112 | + uses: richardsimko/update-tag@v1 |
| 113 | + if: github.ref == 'refs/heads/develop' |
| 114 | + with: |
| 115 | + tag_name: latest |
| 116 | + env: |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + |
| 119 | + - name: Upload nightly release |
| 120 | + uses: svenstaro/upload-release-action@v2 |
| 121 | + if: github.ref == 'refs/heads/develop' |
| 122 | + with: |
| 123 | + tag: "latest" |
| 124 | + release_name: "Nightly Release" |
| 125 | + body: "This is a rolling release built from the latest `develop` branch." |
| 126 | + prerelease: true |
| 127 | + file: install/bin/samedec-${{ matrix.rust }} |
| 128 | + overwrite: true |
| 129 | + |
| 130 | + # Win32 build, on whatever machine github has available |
| 131 | + release_windows: |
| 132 | + runs-on: windows-latest |
| 133 | + |
| 134 | + env: |
| 135 | + CARGO_BUILD_TARGET: x86_64-pc-windows-msvc |
| 136 | + CARGO_INSTALL_ROOT: 'install/' |
| 137 | + RUSTFLAGS: '-C strip=symbols -C target-feature=+crt-static' |
| 138 | + samedec_exe: 'install/bin/samedec.exe' |
| 139 | + samedec_target_exe: install/bin/samedec-x86_64-pc-windows-msvc.exe |
| 140 | + |
| 141 | + steps: |
| 142 | + - uses: actions/checkout@v3 |
| 143 | + |
| 144 | + - name: Record environment |
| 145 | + shell: bash |
| 146 | + run: cargo version |
| 147 | + |
| 148 | + - uses: actions/cache@v3 |
| 149 | + name: Restore Rust cache |
| 150 | + with: |
| 151 | + path: | |
| 152 | + ~/.cargo/bin/ |
| 153 | + ~/.cargo/registry/index/ |
| 154 | + ~/.cargo/registry/cache/ |
| 155 | + ~/.cargo/git/db/ |
| 156 | + target/ |
| 157 | + key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} |
| 158 | + |
| 159 | + - name: Build |
| 160 | + shell: bash |
| 161 | + run: | |
| 162 | + mkdir -p 'install' && |
| 163 | + cargo fetch --locked && |
| 164 | + cargo build --offline --tests --frozen --release --workspace |
| 165 | +
|
| 166 | + - name: Test and install |
| 167 | + shell: bash |
| 168 | + run: | |
| 169 | + cargo test --offline --frozen --release --workspace && |
| 170 | + cargo install --offline --frozen --path=crates/samedec |
| 171 | +
|
| 172 | + - name: Run integration tests |
| 173 | + shell: bash |
| 174 | + run: | |
| 175 | + "$samedec_exe" --version && |
| 176 | + EXPECT="$(cat <sample/long_message.22050.s16le.txt)" && |
| 177 | + OUT="$("$samedec_exe" -r 22050 <sample/long_message.22050.s16le.bin)" && |
| 178 | + echo "$OUT" && |
| 179 | + if [ "$OUT" = "$EXPECT" ]; then |
| 180 | + echo "PASS"; |
| 181 | + else |
| 182 | + echo "FAIL!"; |
| 183 | + exit 1; |
| 184 | + fi |
| 185 | +
|
| 186 | + - name: Copy artifact |
| 187 | + shell: bash |
| 188 | + run: | |
| 189 | + cp "$samedec_exe" "$samedec_target_exe" |
| 190 | +
|
| 191 | + - name: Store artifact |
| 192 | + uses: actions/upload-artifact@v3 |
| 193 | + with: |
| 194 | + name: samedec-${{ env.CARGO_BUILD_TARGET }} |
| 195 | + path: ${{ env.samedec_target_exe }} |
| 196 | + retention-days: 3 |
| 197 | + |
| 198 | + - name: Upload tagged release |
| 199 | + uses: svenstaro/upload-release-action@v2 |
| 200 | + if: startsWith(github.ref, 'refs/tags/samedec-') |
| 201 | + with: |
| 202 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 203 | + file: ${{ env.samedec_target_exe }} |
| 204 | + overwrite: true |
| 205 | + |
| 206 | + - name: Upload nightly release |
| 207 | + uses: svenstaro/upload-release-action@v2 |
| 208 | + if: github.ref == 'refs/heads/develop' |
| 209 | + with: |
| 210 | + tag: "latest" |
| 211 | + release_name: "Nightly Release" |
| 212 | + body: "This is a rolling release built from the latest `develop` branch." |
| 213 | + prerelease: true |
| 214 | + file: ${{ env.samedec_target_exe }} |
| 215 | + overwrite: true |
| 216 | + |
| 217 | + # MacOS build, on whatever machine github has available |
| 218 | + release_macos: |
| 219 | + runs-on: macos-latest |
| 220 | + |
| 221 | + env: |
| 222 | + CARGO_BUILD_TARGET: x86_64-apple-darwin |
| 223 | + CARGO_INSTALL_ROOT: 'install/' |
| 224 | + RUSTFLAGS: '-C strip=symbols' |
| 225 | + samedec_exe: 'install/bin/samedec' |
| 226 | + samedec_target_exe: install/bin/samedec-x86_64-apple-darwin |
| 227 | + |
| 228 | + steps: |
| 229 | + - uses: actions/checkout@v3 |
| 230 | + |
| 231 | + - name: Record environment |
| 232 | + run: cargo version |
| 233 | + |
| 234 | + - uses: actions/cache@v3 |
| 235 | + name: Restore Rust cache |
| 236 | + with: |
| 237 | + path: | |
| 238 | + ~/.cargo/bin/ |
| 239 | + ~/.cargo/registry/index/ |
| 240 | + ~/.cargo/registry/cache/ |
| 241 | + ~/.cargo/git/db/ |
| 242 | + target/ |
| 243 | + key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} |
| 244 | + |
| 245 | + - name: Build |
| 246 | + run: | |
| 247 | + mkdir -p 'install' && |
| 248 | + cargo fetch --locked && |
| 249 | + cargo build --offline --tests --frozen --release --workspace |
| 250 | +
|
| 251 | + - name: Test and install |
| 252 | + run: | |
| 253 | + cargo test --offline --frozen --release --workspace && |
| 254 | + cargo install --offline --frozen --path=crates/samedec |
| 255 | +
|
| 256 | + - name: Run integration tests |
| 257 | + run: | |
| 258 | + "$samedec_exe" --version && |
| 259 | + EXPECT="$(cat <sample/long_message.22050.s16le.txt)" && |
| 260 | + OUT="$("$samedec_exe" -r 22050 <sample/long_message.22050.s16le.bin)" && |
| 261 | + echo "$OUT" && |
| 262 | + if [ "$OUT" = "$EXPECT" ]; then |
| 263 | + echo "PASS"; |
| 264 | + else |
| 265 | + echo "FAIL!"; |
| 266 | + exit 1; |
| 267 | + fi |
| 268 | +
|
| 269 | + - name: Copy artifact |
| 270 | + run: | |
| 271 | + cp "$samedec_exe" "$samedec_target_exe" |
| 272 | +
|
| 273 | + - name: Store artifact |
| 274 | + uses: actions/upload-artifact@v3 |
| 275 | + with: |
| 276 | + name: samedec-${{ env.CARGO_BUILD_TARGET }} |
| 277 | + path: ${{ env.samedec_target_exe }} |
| 278 | + retention-days: 3 |
| 279 | + |
| 280 | + - name: Upload tagged release |
| 281 | + uses: svenstaro/upload-release-action@v2 |
| 282 | + if: startsWith(github.ref, 'refs/tags/samedec-') |
| 283 | + with: |
| 284 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 285 | + file: ${{ env.samedec_target_exe }} |
| 286 | + overwrite: true |
| 287 | + |
| 288 | + - name: Upload nightly release |
| 289 | + uses: svenstaro/upload-release-action@v2 |
| 290 | + if: github.ref == 'refs/heads/develop' |
| 291 | + with: |
| 292 | + tag: "latest" |
| 293 | + release_name: "Nightly Release" |
| 294 | + body: "This is a rolling release built from the latest `develop` branch." |
| 295 | + prerelease: true |
| 296 | + file: ${{ env.samedec_target_exe }} |
| 297 | + overwrite: true |
0 commit comments