chore(ci): test build workflow #3
This file contains 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: | |
- test | |
concurrency: | |
group: '${{ github.workflow }}' | |
cancel-in-progress: false | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
build: | |
name: Build | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- macos-latest | |
- windows-latest | |
- ubuntu-22.04 | |
runs-on: '${{ matrix.platform }}' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Rust setup (mac) | |
if: 'startsWith(matrix.platform, ''macos'')' | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: 'rustfmt, clippy' | |
targets: 'aarch64-apple-darwin, x86_64-apple-darwin' | |
- name: Rust setup | |
if: '!startsWith(matrix.platform, ''macos'')' | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: 'rustfmt, clippy' | |
- name: Setup rust cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
target/** | |
!target/*/release/bundle/*/*.dmg | |
!target/*/release/bundle/*/*.app.tar.gz | |
!target/*/release/bundle/*/*.app.tar.gz.sig | |
!target/release/bundle/*/*.dmg | |
!target/release/bundle/*/*.app.tar.gz | |
!target/release/bundle/*/*.app.tar.gz.sig | |
!target/release/bundle/appimage/*.AppImage | |
!target/release/bundle/appimage/*.AppImage.tar.gz | |
!target/release/bundle/appimage/*.AppImage.tar.gz.sig | |
!target/release/bundle/deb/*.deb | |
!target/release/bundle/rpm/*.rpm | |
!target/release/bundle/msi/*.msi | |
!target/release/bundle/msi/*.msi.zip | |
!target/release/bundle/msi/*.msi.zip.sig | |
!target/release/bundle/nsis/*.exe | |
!target/release/bundle/nsis/*.nsis.zip | |
!target/release/bundle/nsis/*.nsis.zip.sig | |
key: '${{ runner.os }}-rust-target-${{ hashFiles(''**/Cargo.lock'') }}' | |
restore-keys: | | |
${{ runner.os }}-rust-target- | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install pnpm via corepack | |
shell: bash | |
run: | | |
corepack enable | |
corepack prepare --activate | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- name: Setup pnpm cache | |
uses: actions/cache@v4 | |
with: | |
path: '${{ steps.pnpm-cache.outputs.STORE_PATH }}' | |
key: '${{ runner.os }}-pnpm-store-${{ hashFiles(''**/pnpm-lock.yaml'') }}' | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: install dependencies (ubuntu only) | |
if: 'startsWith(matrix.platform, ''ubuntu'')' | |
run: > | |
sudo apt-get update | |
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl | |
wget file libxdo-dev libssl-dev pkg-config | |
libayatana-appindicator3-dev librsvg2-dev | |
- name: Install frontend dependencies | |
run: pnpm install | |
- name: build app (macos) | |
run: >- | |
pnpm --filter=@modrinth/app run tauri build --target | |
universal-apple-darwin --config "tauri-release.conf.json" | |
if: 'startsWith(matrix.platform, ''macos'')' | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
ENABLE_CODE_SIGNING: '${{ secrets.CSC_LINK }}' | |
APPLE_CERTIFICATE: '${{ secrets.CSC_LINK }}' | |
APPLE_CERTIFICATE_PASSWORD: '${{ secrets.CSC_KEY_PASSWORD }}' | |
APPLE_SIGNING_IDENTITY: '${{ secrets.APPLE_SIGNING_IDENTITY }}' | |
APPLE_ID: '${{ secrets.APPLE_ID }}' | |
APPLE_TEAM_ID: '${{ secrets.APPLE_TEAM_ID }}' | |
APPLE_PASSWORD: '${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}' | |
TAURI_SIGNING_PRIVATE_KEY: '${{ secrets.TAURI_PRIVATE_KEY }}' | |
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: '${{ secrets.TAURI_KEY_PASSWORD }}' | |
- name: build app | |
run: >- | |
pnpm --filter=@modrinth/app run tauri build --config | |
"tauri-release.conf.json" | |
id: build_os | |
if: '!startsWith(matrix.platform, ''macos'')' | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
AZURE_CLIENT_ID: '${{ secrets.AZURE_CLIENT_ID }}' | |
AZURE_CLIENT_SECRET: '${{ secrets.AZURE_CLIENT_SECRET }}' | |
AZURE_TENANT_ID: '${{ secrets.AZURE_TENANT_ID }}' | |
TAURI_SIGNING_PRIVATE_KEY: '${{ secrets.TAURI_PRIVATE_KEY }}' | |
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: '${{ secrets.TAURI_KEY_PASSWORD }}' | |
- name: 'upload ${{ matrix.platform }}' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: '${{ matrix.platform }}' | |
path: | | |
target/*/release/bundle/*/*.dmg | |
target/*/release/bundle/*/*.app.tar.gz | |
target/*/release/bundle/*/*.app.tar.gz.sig | |
target/release/bundle/*/*.dmg | |
target/release/bundle/*/*.app.tar.gz | |
target/release/bundle/*/*.app.tar.gz.sig | |
target/release/bundle/*/*.AppImage | |
target/release/bundle/*/*.AppImage.tar.gz | |
target/release/bundle/*/*.AppImage.tar.gz.sig | |
target/release/bundle/*/*.deb | |
target/release/bundle/*/*.rpm | |
target/release/bundle/msi/*.msi | |
target/release/bundle/msi/*.msi.zip | |
target/release/bundle/msi/*.msi.zip.sig | |
target/release/bundle/nsis/*.exe | |
target/release/bundle/nsis/*.nsis.zip | |
target/release/bundle/nsis/*.nsis.zip.sig | |
upload-s3: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: '${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}' | |
aws-secret-access-key: '${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}' | |
endpoint-url: '${{ secrets.CLOUDFLARE_R2_CDN_ENDPOINT }}' | |
- name: Upload to S3 | |
env: | |
S3_ENDPOINT: '${{ secrets.CLOUDFLARE_R2_CDN_ENDPOINT }}' | |
DOWNLOAD_URL_BASE: 'https://cdn.marcuskstudio.live' | |
run: > | |
VERSION=$(node -p "require('./package.json').version") | |
aws s3 cp artifacts s3://launcherbinaries/releases/${VERSION}/ | |
\ | |
--recursive \ | |
--endpoint-url=${S3_ENDPOINT} | |
cat > update-manifest.json << EOF | |
{ | |
"version": "${VERSION}", | |
"notes": "See the assets to download this version and install.", | |
"pub_date": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")", | |
"platforms": { | |
"darwin-x86_64": { | |
"signature": "$(cat artifacts/macos-latest/*/*.app.tar.gz.sig)", | |
"url": "${DOWNLOAD_URL_BASE}/releases/${VERSION}/$(basename artifacts/macos-latest/*/*.app.tar.gz)" | |
}, | |
"darwin-aarch64": { | |
"signature": "$(cat artifacts/macos-latest/*/*.app.tar.gz.sig)", | |
"url": "${DOWNLOAD_URL_BASE}/releases/${VERSION}/$(basename artifacts/macos-latest/*/*.app.tar.gz)" | |
}, | |
"linux-x86_64": { | |
"signature": "$(cat artifacts/ubuntu-22.04/*/*.AppImage.tar.gz.sig)", | |
"url": "${DOWNLOAD_URL_BASE}/releases/${VERSION}/$(basename artifacts/ubuntu-22.04/*/*.AppImage.tar.gz)" | |
}, | |
"windows-x86_64": { | |
"signature": "$(cat artifacts/windows-latest/msi/*.msi.zip.sig)", | |
"url": "${DOWNLOAD_URL_BASE}/releases/${VERSION}/$(basename artifacts/windows-latest/msi/*.msi.zip)" | |
} | |
} | |
} | |
EOF | |
# Upload manifest with custom endpoint | |
aws s3 cp update-manifest.json s3://launcherbinaries/update-manifest.json \ | |
--endpoint-url=${S3_ENDPOINT} |