Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 88 additions & 78 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,81 @@ jobs:
ci:
uses: ./.github/workflows/ci.yml

build:
needs: ci
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
cross: false
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
cross: true
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
cross: false
- target: aarch64-unknown-linux-musl
runner: ubuntu-latest
cross: true
- target: x86_64-apple-darwin
runner: macos-15-intel
cross: false
- target: aarch64-apple-darwin
runner: macos-15
cross: false
- target: x86_64-pc-windows-msvc
runner: windows-latest
cross: false
steps:
- uses: actions/checkout@v6

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Install musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools

- name: Install cross
if: matrix.cross
run: cargo install cross --locked

- name: Build
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }} -p sr-cli
else
cargo build --release --target ${{ matrix.target }} -p sr-cli
fi
shell: bash

- name: Prepare artifact
run: |
if [ -f "target/${{ matrix.target }}/release/sr.exe" ]; then
cp "target/${{ matrix.target }}/release/sr.exe" "sr-${{ matrix.target }}.exe"
else
cp "target/${{ matrix.target }}/release/sr" "sr-${{ matrix.target }}"
chmod +x "sr-${{ matrix.target }}"
fi
shell: bash

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: sr-${{ matrix.target }}
path: sr-${{ matrix.target }}*

release:
name: Release
needs: ci
needs: [ci, build]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down Expand Up @@ -50,14 +122,28 @@ jobs:
- name: Build sr
run: cargo build --release -p sr-cli

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Prepare release assets
run: |
mkdir -p release-assets
for dir in artifacts/sr-*/; do
cp "$dir"/* release-assets/
done
chmod +x release-assets/sr-*[!e]
ls -la release-assets/

- name: Run sr release
id: sr
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
set -uo pipefail
set +e
JSON=$(./target/release/sr release ${{ inputs.force && '--force' || '' }} | tail -1)
JSON=$(./target/release/sr release ${{ inputs.force && '--force' || '' }} --artifacts "release-assets/*" | tail -1)
RC=${PIPESTATUS[0]}
set -e
if [ $RC -eq 0 ]; then
Expand Down Expand Up @@ -116,79 +202,3 @@ jobs:
publish sr-ai
sleep 30
publish sr-cli

build:
needs: release
if: needs.release.outputs.released == 'true'
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
permissions:
contents: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
cross: false
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
cross: true
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
cross: false
- target: aarch64-unknown-linux-musl
runner: ubuntu-latest
cross: true
- target: x86_64-apple-darwin
runner: macos-15-intel
cross: false
- target: aarch64-apple-darwin
runner: macos-15
cross: false
- target: x86_64-pc-windows-msvc
runner: windows-latest
cross: false
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.tag }}

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Install musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools

- name: Install cross
if: matrix.cross
run: cargo install cross --locked

- name: Build
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }} -p sr-cli
else
cargo build --release --target ${{ matrix.target }} -p sr-cli
fi
shell: bash

- name: Upload to release
run: |
TAG="${{ needs.release.outputs.tag }}"
if [ -f "target/${{ matrix.target }}/release/sr.exe" ]; then
cp "target/${{ matrix.target }}/release/sr.exe" "sr-${{ matrix.target }}.exe"
gh release upload "$TAG" "sr-${{ matrix.target }}.exe" --clobber
else
cp "target/${{ matrix.target }}/release/sr" "sr-${{ matrix.target }}"
chmod +x "sr-${{ matrix.target }}"
gh release upload "$TAG" "sr-${{ matrix.target }}" --clobber
fi
shell: bash