Skip to content
Myr

release.yml

This file

Path

.github/workflows/release.yml

386 lines · 12.6 KiB · YAML

Last changed by

ci: attest build provenance for release archivesKobi Hikribefore adoptiondffd776

History of this file

Take it

The walk stopped after 200 commits: lines older than 5f5da48 point at it.

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

lines 1–11why, one step back
1name: release
23# Only do the release on x.y.z tags.4on:5 push:6 tags:7 - "[0-9]+.[0-9]+.[0-9]+"89# We need this to be able to create releases.10permissions:11 contents: write

ci: attest build provenance for release archivesKobi Hikribefore adoptiondffd776

lines 12–13why, one step back
12 id-token: write # for build provenance signing
13 attestations: write # to record the attestation

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

lines 14–84why, one step back
14
15jobs:16 # The create-release job runs purely to initialize the GitHub release itself,17 # and names the release after the `x.y.z` tag that was pushed. It's separate18 # from building the release so that we only create the release once.19 create-release:20 name: create-release21 runs-on: ubuntu-latest22 steps:23 - uses: actions/checkout@v424 - name: Get the release version from the tag25 if: env.VERSION == ''26 run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV27 - name: Show the version28 run: |29 echo "version is: $VERSION"30 - name: Check that tag version and Cargo.toml version are the same31 shell: bash32 run: |33 if ! grep -q "version = \"$VERSION\"" Cargo.toml; then34 echo "version does not match Cargo.toml" >&235 exit 136 fi37 - name: Create GitHub release38 env:39 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}40 run: gh release create $VERSION --draft --verify-tag --title $VERSION41 outputs:42 version: ${{ env.VERSION }}4344 build-release:45 name: build-release46 needs: ['create-release']47 runs-on: ${{ matrix.os }}48 env:49 # For some builds, we use cross to test on 32-bit and big-endian50 # systems.51 CARGO: cargo52 # When CARGO is set to CROSS, this is set to `--target matrix.target`.53 TARGET_FLAGS:54 # When CARGO is set to CROSS, TARGET_DIR includes matrix.target.55 TARGET_DIR: ./target56 # Bump this as appropriate. We pin to a version to make sure CI57 # continues to work as cross releases in the past have broken things58 # in subtle ways.59 CROSS_VERSION: v0.2.560 # Emit backtraces on panics.61 RUST_BACKTRACE: 162 # Build static releases with PCRE2.63 PCRE2_SYS_STATIC: 164 strategy:65 fail-fast: false66 matrix:67 include:68 - build: linux69 os: ubuntu-latest70 rust: nightly71 target: x86_64-unknown-linux-musl72 strip: x86_64-linux-musl-strip73 - build: stable-x8674 os: ubuntu-latest75 rust: stable76 target: i686-unknown-linux-gnu77 strip: x86_64-linux-gnu-strip78 qemu: i38679 - build: stable-aarch6480 os: ubuntu-latest81 rust: stable82 target: aarch64-unknown-linux-gnu83 strip: aarch64-linux-gnu-strip84 qemu: qemu-aarch64

ci: add support for `aarch64-unknown-linux-musl`Andrew Gallantbefore adoption48a6ad9

lines 85–90why, one step back
85 - build: stable-aarch64-musl
86 os: ubuntu-latest87 rust: stable88 target: aarch64-unknown-linux-musl89 strip: aarch64-linux-musl-strip90 qemu: qemu-aarch64

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

lines 91–118why, one step back
91 - build: stable-arm-gnueabihf
92 os: ubuntu-latest93 rust: stable94 target: armv7-unknown-linux-gnueabihf95 strip: arm-linux-gnueabihf-strip96 qemu: qemu-arm97 - build: stable-arm-musleabihf98 os: ubuntu-latest99 rust: stable100 target: armv7-unknown-linux-musleabihf101 strip: arm-linux-musleabihf-strip102 qemu: qemu-arm103 - build: stable-arm-musleabi104 os: ubuntu-latest105 rust: stable106 target: armv7-unknown-linux-musleabi107 strip: arm-linux-musleabi-strip108 qemu: qemu-arm109 - build: stable-s390x110 os: ubuntu-latest111 rust: stable112 target: s390x-unknown-linux-gnu113 strip: s390x-linux-gnu-strip114 qemu: qemu-s390x115 - build: macos116 os: macos-latest117 rust: nightly118 target: x86_64-apple-darwin

release: build aarch64 artifacts for macos on GitHub ActionsAndrew Gallantbefore adoptionc1fc6a5

lines 119–122why, one step back
119 - build: macos
120 os: macos-latest121 rust: nightly122 target: aarch64-apple-darwin

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

lines 123–186why, one step back
123 - build: win-msvc
124 os: windows-latest125 rust: nightly126 target: x86_64-pc-windows-msvc127 - build: win-gnu128 os: windows-latest129 rust: nightly-x86_64-gnu130 target: x86_64-pc-windows-gnu131 - build: winaarch64-msvc132 os: windows-11-arm133 rust: nightly134 target: aarch64-pc-windows-msvc135 - build: win32-msvc136 os: windows-latest137 rust: nightly138 target: i686-pc-windows-msvc139140 steps:141 - name: Checkout repository142 uses: actions/checkout@v4143144 - name: Install packages (Ubuntu)145 if: matrix.os == 'ubuntu-latest'146 shell: bash147 run: |148 ci/ubuntu-install-packages149150 - name: Install Rust151 uses: dtolnay/rust-toolchain@master152 with:153 toolchain: ${{ matrix.rust }}154 target: ${{ matrix.target }}155156 - name: Use Cross157 if: matrix.os == 'ubuntu-latest' && matrix.target != ''158 shell: bash159 run: |160 # In the past, new releases of 'cross' have broken CI. So for now, we161 # pin it. We also use their pre-compiled binary releases because cross162 # has over 100 dependencies and takes a bit to compile.163 dir="$RUNNER_TEMP/cross-download"164 mkdir "$dir"165 echo "$dir" >> $GITHUB_PATH166 cd "$dir"167 curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz"168 tar xf cross-x86_64-unknown-linux-musl.tar.gz169 echo "CARGO=cross" >> $GITHUB_ENV170171 - name: Set target variables172 shell: bash173 run: |174 echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV175 echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV176177 - name: Show command used for Cargo178 shell: bash179 run: |180 echo "cargo command is: ${{ env.CARGO }}"181 echo "target flag is: ${{ env.TARGET_FLAGS }}"182 echo "target dir is: ${{ env.TARGET_DIR }}"183184 - name: Build release binary185 shell: bash186 run: |

release: finally switch to LTO for release binariesAndrew Gallantbefore adoption4c95373

line 187why, one step back
187 ${{ env.CARGO }} build --verbose --profile release-lto --features pcre2 ${{ env.TARGET_FLAGS }}

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

line 188why, one step back
188 if [[ "${{ matrix.os }}" == windows-* ]]; then

release: finally switch to LTO for release binariesAndrew Gallantbefore adoption4c95373

line 189why, one step back
189 bin="target/${{ matrix.target }}/release-lto/rg.exe"

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

line 190why, one step back
190 else

release: finally switch to LTO for release binariesAndrew Gallantbefore adoption4c95373

line 191why, one step back
191 bin="target/${{ matrix.target }}/release-lto/rg"

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

lines 192–285why, one step back
192 fi
193 echo "BIN=$bin" >> $GITHUB_ENV194195 - name: Strip release binary (macos)196 if: matrix.os == 'macos-latest'197 shell: bash198 run: strip "$BIN"199200 - name: Strip release binary (cross)201 if: env.CARGO == 'cross'202 shell: bash203 run: |204 docker run --rm -v \205 "$PWD/target:/target:Z" \206 "ghcr.io/cross-rs/${{ matrix.target }}:main" \207 "${{ matrix.strip }}" \208 "/$BIN"209210 - name: Determine archive name211 shell: bash212 run: |213 version="${{ needs.create-release.outputs.version }}"214 echo "ARCHIVE=ripgrep-$version-${{ matrix.target }}" >> $GITHUB_ENV215216 - name: Creating directory for archive217 shell: bash218 run: |219 mkdir -p "$ARCHIVE"/{complete,doc}220 cp "$BIN" "$ARCHIVE"/221 cp {README.md,COPYING,UNLICENSE,LICENSE-MIT} "$ARCHIVE"/222 cp {CHANGELOG.md,FAQ.md,GUIDE.md} "$ARCHIVE"/doc/223224 - name: Generate man page and completions (no emulation)225 if: matrix.qemu == ''226 shell: bash227 run: |228 "$BIN" --version229 "$BIN" --generate complete-bash > "$ARCHIVE/complete/rg.bash"230 "$BIN" --generate complete-fish > "$ARCHIVE/complete/rg.fish"231 "$BIN" --generate complete-powershell > "$ARCHIVE/complete/_rg.ps1"232 "$BIN" --generate complete-zsh > "$ARCHIVE/complete/_rg"233 "$BIN" --generate man > "$ARCHIVE/doc/rg.1"234235 - name: Generate man page and completions (emulation)236 if: matrix.qemu != ''237 shell: bash238 run: |239 docker run --rm -v \240 "$PWD/target:/target:Z" \241 "ghcr.io/cross-rs/${{ matrix.target }}:main" \242 "${{ matrix.qemu }}" "/$BIN" --version243 docker run --rm -v \244 "$PWD/target:/target:Z" \245 "ghcr.io/cross-rs/${{ matrix.target }}:main" \246 "${{ matrix.qemu }}" "/$BIN" \247 --generate complete-bash > "$ARCHIVE/complete/rg.bash"248 docker run --rm -v \249 "$PWD/target:/target:Z" \250 "ghcr.io/cross-rs/${{ matrix.target }}:main" \251 "${{ matrix.qemu }}" "/$BIN" \252 --generate complete-fish > "$ARCHIVE/complete/rg.fish"253 docker run --rm -v \254 "$PWD/target:/target:Z" \255 "ghcr.io/cross-rs/${{ matrix.target }}:main" \256 "${{ matrix.qemu }}" "/$BIN" \257 --generate complete-powershell > "$ARCHIVE/complete/_rg.ps1"258 docker run --rm -v \259 "$PWD/target:/target:Z" \260 "ghcr.io/cross-rs/${{ matrix.target }}:main" \261 "${{ matrix.qemu }}" "/$BIN" \262 --generate complete-zsh > "$ARCHIVE/complete/_rg"263 docker run --rm -v \264 "$PWD/target:/target:Z" \265 "ghcr.io/cross-rs/${{ matrix.target }}:main" \266 "${{ matrix.qemu }}" "/$BIN" \267 --generate man > "$ARCHIVE/doc/rg.1"268269 - name: Build archive (Windows)270 shell: bash271 if: startsWith(matrix.os, 'windows')272 run: |273 7z a "$ARCHIVE.zip" "$ARCHIVE"274 certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256"275 echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV276 echo "ASSET_SUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV277278 - name: Build archive (Unix)279 shell: bash280 if: ${{ !startsWith(matrix.os, 'windows') }}281 run: |282 tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"283 shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"284 echo "ASSET=$ARCHIVE.tar.gz" >> $GITHUB_ENV285 echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >> $GITHUB_ENV

ci: attest build provenance for release archivesKobi Hikribefore adoptiondffd776

lines 286–290why, one step back
286
287 - name: Attest build provenance288 uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0289 with:290 subject-path: ${{ env.ASSET }}

globset: support nested alternatesLuke Sandbergbefore adoption5f5da48

lines 291–386why, one step back
291
292 - name: Upload release archive293 env:294 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}295 shell: bash296 run: |297 version="${{ needs.create-release.outputs.version }}"298 gh release upload "$version" ${{ env.ASSET }} ${{ env.ASSET_SUM }}299300 build-release-deb:301 name: build-release-deb302 needs: ['create-release']303 runs-on: ubuntu-latest304 env:305 TARGET: x86_64-unknown-linux-musl306 # Emit backtraces on panics.307 RUST_BACKTRACE: 1308 # Since we're distributing the dpkg, we don't know whether the user will309 # have PCRE2 installed, so just do a static build.310 PCRE2_SYS_STATIC: 1311312 steps:313 - name: Checkout repository314 uses: actions/checkout@v4315316 - name: Install packages (Ubuntu)317 shell: bash318 run: |319 ci/ubuntu-install-packages320321 - name: Install Rust322 uses: dtolnay/rust-toolchain@master323 with:324 toolchain: nightly325 target: ${{ env.TARGET }}326327 - name: Install cargo-deb328 shell: bash329 run: |330 cargo install cargo-deb331332 # 'cargo deb' does not seem to provide a way to specify an asset that is333 # created at build time, such as ripgrep's man page. To work around this,334 # we force a debug build, copy out the man page (and shell completions)335 # produced from that build, put it into a predictable location and then336 # build the deb, which knows where to look.337 - name: Build debug binary to create release assets338 shell: bash339 run: |340 cargo build --target ${{ env.TARGET }}341 bin="target/${{ env.TARGET }}/debug/rg"342 echo "BIN=$bin" >> $GITHUB_ENV343344 - name: Create deployment directory345 shell: bash346 run: |347 dir=deployment/deb348 mkdir -p "$dir"349 echo "DEPLOY_DIR=$dir" >> $GITHUB_ENV350351 - name: Generate man page352 shell: bash353 run: |354 "$BIN" --generate man > "$DEPLOY_DIR/rg.1"355356 - name: Generate shell completions357 shell: bash358 run: |359 "$BIN" --generate complete-bash > "$DEPLOY_DIR/rg.bash"360 "$BIN" --generate complete-fish > "$DEPLOY_DIR/rg.fish"361 "$BIN" --generate complete-zsh > "$DEPLOY_DIR/_rg"362363 - name: Build release binary364 shell: bash365 run: |366 cargo deb --profile deb --target ${{ env.TARGET }}367 version="${{ needs.create-release.outputs.version }}"368 echo "DEB_DIR=target/${{ env.TARGET }}/debian" >> $GITHUB_ENV369 echo "DEB_NAME=ripgrep_$version-1_amd64.deb" >> $GITHUB_ENV370371 - name: Create sha256 sum of deb file372 shell: bash373 run: |374 cd "$DEB_DIR"375 sum="$DEB_NAME.sha256"376 shasum -a 256 "$DEB_NAME" > "$sum"377 echo "SUM=$sum" >> $GITHUB_ENV378379 - name: Upload release archive380 env:381 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}382 shell: bash383 run: |384 cd "$DEB_DIR"385 version="${{ needs.create-release.outputs.version }}"386 gh release upload "$version" "$DEB_NAME" "$SUM"