Skip to content

fix(flathub): use root Cargo.lock for cargo-sources.json (#43) #39

fix(flathub): use root Cargo.lock for cargo-sources.json (#43)

fix(flathub): use root Cargo.lock for cargo-sources.json (#43) #39

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short
permissions:
contents: write
jobs:
extract-api-key:
runs-on: ubuntu-latest
outputs:
curse_key: ${{ steps.extract.outputs.curse_key }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python dependencies
run: pip install requests
- name: Extract CurseForge API key
id: extract
run: |
python3 curseforge_key_extractor.py 2>&1 | tee /tmp/curse_output.txt
cat /tmp/curse_output.txt
CURSE_KEY=$(grep "^api key:" /tmp/curse_output.txt | cut -d' ' -f3)
echo "extracted curse key: $CURSE_KEY"
if [ -z "$CURSE_KEY" ]; then
echo "failed to extract curse key" >&2
exit 1
fi
echo "curse_key=$CURSE_KEY" >> $GITHUB_OUTPUT
build-cli:
needs: extract-api-key
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
artifact: shard-cli-macos-arm64
- platform: macos-latest
target: x86_64-apple-darwin
artifact: shard-cli-macos-x64
- platform: windows-latest
target: x86_64-pc-windows-msvc
artifact: shard-cli-windows-x64
- platform: ubuntu-22.04
target: x86_64-unknown-linux-gnu
artifact: shard-cli-linux-x64
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: '. -> target'
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev
- name: Build CLI
env:
SHARD_MS_CLIENT_ID: ${{ secrets.SHARD_MS_CLIENT_ID }}
SHARD_CURSEFORGE_API_KEY: ${{ needs.extract-api-key.outputs.curse_key }}
run: cargo build --release --target ${{ matrix.target }} -p shard
- name: Prepare artifact (Unix)
if: matrix.platform != 'windows-latest'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/shard dist/
cd dist && tar -czvf ../${{ matrix.artifact }}.tar.gz shard
- name: Prepare artifact (Windows)
if: matrix.platform == 'windows-latest'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item target/${{ matrix.target }}/release/shard.exe dist/
Compress-Archive -Path dist/shard.exe -DestinationPath ${{ matrix.artifact }}.zip
- name: Upload CLI artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
${{ matrix.artifact }}.tar.gz
${{ matrix.artifact }}.zip
if-no-files-found: ignore
build-desktop:
needs: extract-api-key
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
name: macos-arm64
- platform: macos-latest
target: x86_64-apple-darwin
name: macos-x64
- platform: windows-latest
target: x86_64-pc-windows-msvc
name: windows-x64
- platform: ubuntu-22.04
target: x86_64-unknown-linux-gnu
name: linux-x64
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: './desktop/src-tauri -> target'
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
libssl-dev
- name: Install frontend dependencies
working-directory: desktop
run: bun install --frozen-lockfile
- name: Build Tauri app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
SHARD_MS_CLIENT_ID: ${{ secrets.SHARD_MS_CLIENT_ID }}
SHARD_CURSEFORGE_API_KEY: ${{ needs.extract-api-key.outputs.curse_key }}
with:
projectPath: desktop
args: --target ${{ matrix.target }}
- name: Rename artifacts for clarity
shell: bash
run: |
mkdir -p renamed-artifacts
if [ "${{ matrix.platform }}" = "macos-latest" ]; then
find target/${{ matrix.target }}/release/bundle -name "*.dmg" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.dmg \; 2>/dev/null || true
find target/${{ matrix.target }}/release/bundle -name "*.app.tar.gz" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.app.tar.gz \; 2>/dev/null || true
elif [ "${{ matrix.platform }}" = "windows-latest" ]; then
find target/${{ matrix.target }}/release/bundle -name "*.msi" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.msi \; 2>/dev/null || true
find target/${{ matrix.target }}/release/bundle -name "*-setup.exe" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}-setup.exe \; 2>/dev/null || true
elif [ "${{ matrix.platform }}" = "ubuntu-22.04" ]; then
find target/${{ matrix.target }}/release/bundle -name "*.AppImage" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.AppImage \; 2>/dev/null || true
find target/${{ matrix.target }}/release/bundle -name "*.deb" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.deb \; 2>/dev/null || true
fi
- name: Collect updater signatures
shell: bash
run: |
mkdir -p renamed-artifacts
if [ "${{ matrix.platform }}" = "macos-latest" ]; then
find target/${{ matrix.target }}/release/bundle -name "*.app.tar.gz.sig" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.app.tar.gz.sig \; 2>/dev/null || true
elif [ "${{ matrix.platform }}" = "windows-latest" ]; then
find target/${{ matrix.target }}/release/bundle -name "*.msi.sig" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.msi.sig \; 2>/dev/null || true
find target/${{ matrix.target }}/release/bundle -name "*-setup.exe.sig" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}-setup.exe.sig \; 2>/dev/null || true
elif [ "${{ matrix.platform }}" = "ubuntu-22.04" ]; then
find target/${{ matrix.target }}/release/bundle -name "*.AppImage.sig" -exec cp {} renamed-artifacts/shard-launcher-${{ matrix.name }}.AppImage.sig \; 2>/dev/null || true
fi
- name: Upload desktop artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-${{ matrix.name }}
path: renamed-artifacts/*
if-no-files-found: ignore
release:
needs: [build-cli, build-desktop]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifacts
run: |
mkdir -p release-files
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.dmg" -o -name "*.msi" -o -name "*.exe" -o -name "*.AppImage" -o -name "*.deb" -o -name "*.sig" \) -exec cp {} release-files/ \;
ls -la release-files/
- name: Build updater manifest
working-directory: release-files
env:
TAG: ${{ github.ref_name }}
run: |
node - <<'NODE'
const fs = require("fs");
const tag = process.env.TAG;
const version = tag.startsWith("v") ? tag.slice(1) : tag;
const baseUrl = `https://github.com/th0rgal/shard/releases/download/${tag}`;
const readSig = (file) => fs.readFileSync(file, "utf8").trim();
const manifest = {
version,
notes: "",
platforms: {
"darwin-aarch64": {
url: `${baseUrl}/shard-launcher-macos-arm64.app.tar.gz`,
signature: readSig("shard-launcher-macos-arm64.app.tar.gz.sig")
},
"darwin-x86_64": {
url: `${baseUrl}/shard-launcher-macos-x64.app.tar.gz`,
signature: readSig("shard-launcher-macos-x64.app.tar.gz.sig")
},
"linux-x86_64": {
url: `${baseUrl}/shard-launcher-linux-x64.AppImage`,
signature: readSig("shard-launcher-linux-x64.AppImage.sig")
},
"windows-x86_64": {
url: `${baseUrl}/shard-launcher-windows-x64-setup.exe`,
signature: readSig("shard-launcher-windows-x64-setup.exe.sig")
}
}
};
fs.writeFileSync("latest.json", JSON.stringify(manifest, null, 2) + "\n");
NODE
- name: Generate checksums
working-directory: release-files
run: |
sha256sum * > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
draft: true
name: Shard ${{ github.ref_name }}
body: |
## Desktop App (Shard Launcher)
| Platform | Download |
|----------|----------|
| macOS (Apple Silicon) | [`shard-launcher-macos-arm64.dmg`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-launcher-macos-arm64.dmg) |
| macOS (Intel) | [`shard-launcher-macos-x64.dmg`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-launcher-macos-x64.dmg) |
| Windows (installer) | [`shard-launcher-windows-x64.msi`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-launcher-windows-x64.msi) |
| Windows (setup) | [`shard-launcher-windows-x64-setup.exe`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-launcher-windows-x64-setup.exe) |
| Linux (AppImage) | [`shard-launcher-linux-x64.AppImage`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-launcher-linux-x64.AppImage) |
| Linux (Debian) | [`shard-launcher-linux-x64.deb`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-launcher-linux-x64.deb) |
## CLI
| Platform | Download |
|----------|----------|
| macOS (Apple Silicon) | [`shard-cli-macos-arm64.tar.gz`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-cli-macos-arm64.tar.gz) |
| macOS (Intel) | [`shard-cli-macos-x64.tar.gz`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-cli-macos-x64.tar.gz) |
| Windows | [`shard-cli-windows-x64.zip`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-cli-windows-x64.zip) |
| Linux | [`shard-cli-linux-x64.tar.gz`](https://github.com/th0rgal/shard/releases/download/${{ github.ref_name }}/shard-cli-linux-x64.tar.gz) |
## Installation
### Desktop App
**macOS**: Download the `.dmg`, open it, and drag Shard to Applications.
**Windows**: Run the `.msi` installer or the setup `.exe`.
**Linux**: Make the `.AppImage` executable (`chmod +x`) and run, or install the `.deb` package.
### CLI
**macOS/Linux**:
```bash
tar -xzf shard-cli-*.tar.gz
sudo mv shard /usr/local/bin/
```
**Windows**: Extract the `.zip` and add `shard.exe` to your PATH.
## Checksums
See `SHA256SUMS.txt` for file integrity verification.
files: release-files/*