Skip to content

fix: authenticate ripgrep release lookup #48

fix: authenticate ripgrep release lookup

fix: authenticate ripgrep release lookup #48

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
env:
CARGO_TERM_COLOR: always
jobs:
# ── Matrix build ─────────────────────────────────────────────────────────
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
ext: ""
archive: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
ext: ""
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
ext: ""
archive: tar.gz
- os: macos-latest
target: x86_64-apple-darwin
ext: ""
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: ".exe"
archive: zip
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
- uses: mlugg/setup-zig@v2
if: runner.os == 'Linux'
- name: Install cargo-zigbuild
uses: taiki-e/install-action@v2
if: runner.os == 'Linux'
with:
tool: cargo-zigbuild@0.22.3
- name: Build release binary (x86_64 Linux)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo zigbuild --release --target ${{ matrix.target }} -p devo-cli
- name: Build release binary (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: cargo zigbuild --release --target ${{ matrix.target }} -p devo-cli
- name: Build release binary (macOS)
if: runner.os == 'macOS'
run: cargo build --release --target ${{ matrix.target }} -p devo-cli
- name: Build release binary (Windows)
if: runner.os == 'Windows'
run: cargo build --release --target ${{ matrix.target }} -p devo-cli
- name: Strip symbols (macOS)
if: runner.os == 'macOS'
run: strip target/${{ matrix.target }}/release/devo${{ matrix.ext }}
- name: Prepare staging directory
shell: bash
run: |
staging=devo-${{ github.ref_name }}-${{ matrix.target }}
mkdir -p "$staging"
cp target/${{ matrix.target }}/release/devo${{ matrix.ext }} "$staging/"
cp README.md LICENSE "$staging/" 2>/dev/null || true
echo "STAGING=$staging" >> "$GITHUB_ENV"
- name: Create tar.gz archive (Linux/macOS)
if: runner.os != 'Windows'
run: tar czf "${{ env.STAGING }}.tar.gz" "${{ env.STAGING }}"
- name: Create zip archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$staging = "$env:STAGING"
Compress-Archive -Path "$staging/*" -DestinationPath "$staging.zip"
- uses: actions/upload-artifact@v4
with:
name: devo-${{ github.ref_name }}-${{ matrix.target }}
path: devo-${{ github.ref_name }}-${{ matrix.target }}.*
# ── Desktop app builds ───────────────────────────────────────────────────
desktop:
name: Build desktop ${{ matrix.platform }} ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
matrix:
include:
- os: macos-latest
platform: mac
arch: arm64
target: aarch64-apple-darwin
rg_target: aarch64-apple-darwin
script: package:mac:arm64
- os: macos-latest
platform: mac
arch: x64
target: x86_64-apple-darwin
rg_target: x86_64-apple-darwin
script: package:mac:x64
- os: windows-latest
platform: windows
arch: x64
target: x86_64-pc-windows-msvc
rg_target: x86_64-pc-windows-msvc
script: package:win:x64
- os: windows-latest
platform: windows
arch: arm64
target: aarch64-pc-windows-msvc
rg_target: aarch64-pc-windows-msvc
script: package:win:arm64
- os: ubuntu-latest
platform: linux
arch: x64
target: x86_64-unknown-linux-musl
rg_target: x86_64-unknown-linux-musl
script: package:linux:x64
- os: ubuntu-latest
platform: linux
arch: arm64
target: aarch64-unknown-linux-musl
rg_target: aarch64-unknown-linux-gnu
script: package:linux:arm64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: desktop-${{ matrix.target }}
- uses: mlugg/setup-zig@v2
if: runner.os == 'Linux'
- name: Install cargo-zigbuild
uses: taiki-e/install-action@v2
if: runner.os == 'Linux'
with:
tool: cargo-zigbuild@0.22.3
- uses: oven-sh/setup-bun@v2
- name: Install Linux packaging dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y rpm
- name: Download ripgrep sidecar (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
rg_version="$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/BurntSushi/ripgrep/releases/latest \
| sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' \
| sed -n '1p')"
if [ -z "$rg_version" ]; then
echo "Failed to resolve latest ripgrep release version" >&2
exit 1
fi
archive="ripgrep-${rg_version}-${{ matrix.rg_target }}.tar.gz"
tmp_dir="$(mktemp -d)"
curl -fsSL "https://github.com/BurntSushi/ripgrep/releases/download/${rg_version}/${archive}" -o "${tmp_dir}/${archive}"
tar -xzf "${tmp_dir}/${archive}" -C "$tmp_dir"
rg_bin="$(find "$tmp_dir" -type f -name rg | sed -n '1p')"
if [ -z "$rg_bin" ]; then
echo "rg not found in ${archive}" >&2
exit 1
fi
chmod +x "$rg_bin"
"$rg_bin" --version
echo "DEVO_DESKTOP_RUNTIME_RG_BIN=$rg_bin" >> "$GITHUB_ENV"
- name: Download ripgrep sidecar (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
$headers = @{
"Accept" = "application/vnd.github+json"
"Authorization" = "Bearer $env:GITHUB_TOKEN"
"X-GitHub-Api-Version" = "2022-11-28"
}
$release = Invoke-RestMethod -Headers $headers -Uri "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest"
$rgVersion = $release.tag_name
if ([string]::IsNullOrWhiteSpace($rgVersion)) {
throw "Failed to resolve latest ripgrep release version"
}
$archive = "ripgrep-$rgVersion-${{ matrix.rg_target }}.zip"
$tmpDir = Join-Path $env:RUNNER_TEMP "ripgrep"
New-Item -ItemType Directory -Force -Path $tmpDir | Out-Null
$archivePath = Join-Path $tmpDir $archive
Invoke-WebRequest -Uri "https://github.com/BurntSushi/ripgrep/releases/download/$rgVersion/$archive" -OutFile $archivePath
Expand-Archive -Path $archivePath -DestinationPath $tmpDir -Force
$rg = Get-ChildItem -Recurse -Filter "rg.exe" -Path $tmpDir | Select-Object -First 1
if (-not $rg) {
throw "rg.exe not found in $archive"
}
& $rg.FullName --version
"DEVO_DESKTOP_RUNTIME_RG_BIN=$($rg.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install desktop dependencies
working-directory: apps/desktop
run: bun install --frozen-lockfile
- name: Build desktop package
working-directory: apps/desktop
run: bun run ${{ matrix.script }}
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
- uses: actions/upload-artifact@v4
with:
name: devo-desktop-${{ github.ref_name }}-${{ matrix.platform }}-${{ matrix.arch }}
path: |
apps/desktop/release/*.AppImage
apps/desktop/release/*.blockmap
apps/desktop/release/*.deb
apps/desktop/release/*.dmg
apps/desktop/release/*.exe
apps/desktop/release/*.rpm
apps/desktop/release/*.yml
apps/desktop/release/*.zip
# ── Create GitHub Release ──────────────────────────────────────────────
release:
name: Create Release
needs: [build, desktop]
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: artifacts
- name: Collect individual release assets
run: |
mkdir -p release-assets
find artifacts -maxdepth 1 -type f \
\( -name '*.AppImage' \
-o -name '*.deb' \
-o -name '*.dmg' \
-o -name '*.exe' \
-o -name '*.rpm' \
-o -name '*.tar.gz' \
-o -name '*.zip' \) \
-exec cp {} release-assets/ \;
find release-assets -maxdepth 1 -type f -print | sort
- name: Generate release notes
run: |
cat > release-notes.md <<'NOTES'
## Install
### Linux / macOS
```bash
curl -fsSL https://raw.githubusercontent.com/7df-lab/devo/main/install.sh | sh
```
### Windows
```powershell
irm 'https://raw.githubusercontent.com/7df-lab/devo/main/install.ps1' | iex
```
---
NOTES
- name: Create release
uses: softprops/action-gh-release@v2
with:
body_path: release-notes.md
draft: true
files: release-assets/*
generate_release_notes: true