style: fix cargo fmt formatting in config.rs #128
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: "Re-release the current tag (use when a previous release partially failed)" | |
| type: boolean | |
| default: false | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| 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 | |
| with: | |
| path: sr | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| workspaces: sr | |
| - 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 | |
| working-directory: sr | |
| 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 | |
| working-directory: sr | |
| 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@v7 | |
| with: | |
| name: sr-${{ matrix.target }} | |
| path: sr/sr-${{ matrix.target }}* | |
| release: | |
| name: Release | |
| needs: [ci, build] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Generate app token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ secrets.SR_RELEASER_APP_ID }} | |
| private-key: ${{ secrets.SR_RELEASER_PRIVATE_KEY }} | |
| repositories: ${{ github.event.repository.name }} | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ steps.app-token.outputs.token }} | |
| path: sr | |
| - name: Configure git identity | |
| working-directory: sr | |
| run: | | |
| git config user.name "sr-releaser[bot]" | |
| git config user.email "sr-releaser[bot]@users.noreply.github.com" | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: sr | |
| - name: Build sr | |
| working-directory: sr | |
| run: cargo build --release -p sr-cli | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: sr/artifacts | |
| - name: Prepare release assets | |
| working-directory: sr | |
| 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 | |
| working-directory: sr | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| set -uo pipefail | |
| set +e | |
| JSON=$(./target/release/sr release ${{ inputs.force && '--force' || '' }} --artifacts "release-assets/*" | tail -1) | |
| RC=${PIPESTATUS[0]} | |
| set -e | |
| if [ $RC -eq 0 ]; then | |
| echo "released=true" >> "$GITHUB_OUTPUT" | |
| echo "version=$(echo "$JSON" | jq -r '.version')" >> "$GITHUB_OUTPUT" | |
| elif [ $RC -eq 2 ]; then | |
| echo "No releasable commits — skipping release" | |
| echo "released=false" >> "$GITHUB_OUTPUT" | |
| else | |
| exit $RC | |
| fi | |
| outputs: | |
| released: ${{ steps.sr.outputs.released }} | |
| tag: v${{ steps.sr.outputs.version }} | |
| publish: | |
| needs: release | |
| if: needs.release.outputs.released == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.release.outputs.tag }} | |
| path: sr | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: sr | |
| - name: Authenticate with crates.io | |
| id: auth | |
| uses: rust-lang/crates-io-auth-action@v1 | |
| - name: Publish to crates.io | |
| working-directory: sr | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | |
| run: | | |
| publish() { | |
| local output | |
| output=$(cargo publish -p "$1" 2>&1) && return 0 | |
| if echo "$output" | grep -q "already exists"; then | |
| echo "$1 already published, skipping" | |
| return 0 | |
| fi | |
| echo "$output" >&2 | |
| return 1 | |
| } | |
| publish sr-core | |
| sleep 30 | |
| publish sr-git | |
| publish sr-github | |
| sleep 30 | |
| publish sr-ai | |
| sleep 30 | |
| publish sr-cli |