Skip to content

Draft Release

Draft Release #53

Workflow file for this run

name: Draft Release
on:
workflow_dispatch:
inputs:
prerelease:
required: true
type: boolean
description: "Is this a pre-release? If not, this will be considered the latest release"
default: true
version:
required: false
type: string
description: "Optionally input a custom version. If not, the version string will automatically be generated based on the version in package.json"
env:
UPDATE_URL_STABLE: "https://surrealist.app/latest.json"
UPDATE_URL_BETA: "https://beta.surrealist.app/latest.json"
CALLBACK_URL_STABLE: "https://surrealist.app/cloud/callback"
CALLBACK_URL_BETA: "https://beta.surrealist.app/cloud/callback"
jobs:
version:
name: Extract version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Set inputted version
if: ${{ inputs.version }}
run: |
pnpm pkg set version=${{ inputs.version }}
- name: Validate unique version
run: |
v=$(pnpm pkg get version)
v=${v:1:-1}
TAG="surrealist-v$v"
if git show-ref --tags --verify --quiet "refs/tags/${TAG}"; then
echo "ERR: Tag ${TAG} already exists! Please bump the version."
exit 1
else
echo "OK: All clear! No such tag as ${TAG} found."
fi
- name: Extract version
id: extract_version
uses: Saionaro/[email protected]
draft:
name: Draft release
needs:
- version
permissions:
contents: write
strategy:
fail-fast: true
matrix:
settings:
- platform: "macos-latest"
id: 'macos-aarch64'
args: "--target aarch64-apple-darwin --verbose"
- platform: "macos-latest"
id: 'macos-x86_64'
args: "--target x86_64-apple-darwin --verbose"
- platform: "ubuntu-22.04"
id: 'linux'
args: "--verbose"
- platform: "windows-latest"
id: 'windows'
args: "--verbose"
runs-on: ${{ matrix.settings.platform }}
steps:
- name: Information
run: echo "Building Surrealist Desktop v${{ needs.version.outputs.version }} for ${{ matrix.settings.id }}"
- name: Code checkout
uses: actions/checkout@v4
- name: Install dependencies (ubuntu only)
if: matrix.settings.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"
- name: Setup jq
uses: dcarbone/install-jq-action@v2
- name: Install frontend dependencies
run: pnpm i --frozen-lockfile
- name: Generate license report
run: pnpm license-report
- name: Set version
run: pnpm pkg set version=${{ needs.version.outputs.version }}
- name: Persist Apple API Key
if: matrix.settings.platform == 'macos-latest'
env:
APPLE_API_KEY_CONTENT: ${{ secrets.APPLE_API_KEY_CONTENT }}
shell: bash
run: echo "$APPLE_API_KEY_CONTENT" >> ${{ github.workspace }}/apple-api-key.p8
- name: Configure variables
shell: bash
run: |
if [ "${{ inputs.prerelease }}" == "true" ]; then
echo "UPDATE_URL=${{ env.UPDATE_URL_BETA }}" >> $GITHUB_ENV
echo "CALLBACK_URL=${{ env.CALLBACK_URL_BETA }}" >> $GITHUB_ENV
else
echo "UPDATE_URL=${{ env.UPDATE_URL_STABLE }}" >> $GITHUB_ENV
echo "CALLBACK_URL=${{ env.CALLBACK_URL_STABLE }}" >> $GITHUB_ENV
fi
- name: Debug environment
run: |
echo "Update URL: ${{ env.UPDATE_URL }}"
echo "Callback URL: ${{ env.CALLBACK_URL }}"
- name: Configure update endpoint
shell: bash
run: |
jq '.plugins.updater.endpoints[0] = "${{ env.UPDATE_URL }}"' ./src-tauri/tauri.conf.json > ./src-tauri/tauri.conf.temp
mv -f ./src-tauri/tauri.conf.temp ./src-tauri/tauri.conf.json
- name: Build and draft release
uses: tauri-apps/tauri-action@v0
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
VITE_SURREALIST_PREVIEW: "${{ inputs.prerelease }}"
VITE_CLOUD_CLIENT_ID: "OuFa4OeeKveeRq1G6xIPgrl6EBUJtxLR"
VITE_CLOUD_CALLBACK_URL: "${{ env.CALLBACK_URL }}"
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
APPLE_API_KEY_PATH: ${{ github.workspace }}/apple-api-key.p8
CI: false
with:
appVersion: surrealist-v${{ needs.version.outputs.version }}
releaseId: surrealist-v${{ needs.version.outputs.version }}
tagName: surrealist-v${{ needs.version.outputs.version }}
args: "${{ matrix.settings.args }}"
releaseName: 'Surrealist v${{ needs.version.outputs.version }}'
releaseBody: Surrealist update v${{ needs.version.outputs.version }}
releaseDraft: true
prerelease: ${{ inputs.prerelease }}