Skip to content

Merge pull request #519 from Brendonovich/fix_webhook_error #235

Merge pull request #519 from Brendonovich/fix_webhook_error

Merge pull request #519 from Brendonovich/fix_webhook_error #235

name: "Release Desktop"
on:
workflow_dispatch:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CN_APP_SLUG: macrograph
APP_CARGO_TOML: apps/desktop/src-tauri/Cargo.toml
jobs:
draft:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.read_version.outputs.value }}
needs_release: ${{ steps.create_tag.outputs.tag_existed != 'true' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Read version number
uses: SebRollen/toml-action@v1.0.2
id: read_version
with:
file: ${{ env.APP_CARGO_TOML }}
field: "package.version"
- name: Create tag
id: create_tag
uses: actions/github-script@v7
with:
script: |
const tag = "${{ steps.read_version.outputs.value }}";
const tagRef = `tags/${tag}`;
const TAG_EXISTED = "tag_existed";
async function main() {
let tagExisted = true;
try {
await github.rest.git.getRef({
ref: tagRef,
owner: context.repo.owner,
repo: context.repo.repo,
});
tagExisted = true;
core.notice(`Release skipped as tag '${tag}' already exists. Update the version in '${{ env.APP_CARGO_TOML }}' to perform a release.`);
} catch (error) {
if ("status" in error && error.status === 404) tagExisted = false;
else throw error;
}
core.setOutput(TAG_EXISTED, tagExisted);
if (!tagExisted)
await github.rest.git.createRef({
ref: `refs/${tagRef}`,
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
});
}
main();
- name: Create draft release
if: ${{ steps.create_tag.outputs.tag_existed != 'true' }}
uses: crabnebula-dev/cloud-release@v0.1.0
with:
command: release draft ${{ env.CN_APP_SLUG }} "${{ steps.read_version.outputs.value }}" --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
build:
needs: draft
if: ${{ needs.draft.outputs.needs_release == 'true' }}
runs-on: ${{ matrix.settings.host }}
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v3
- uses: apple-actions/import-codesign-certs@v2
if: ${{ runner.os == 'macOS' }}
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
- uses: ./.github/actions/setup-js
- uses: ./.github/actions/setup-rust
with:
target: ${{ matrix.settings.target }}
- uses: ./.github/actions/install-desktop-deps
- name: Build Desktop
run: pnpm desktop tauri build --ci --target ${{ matrix.settings.target }}
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }}
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 }}
- name: Upload assets to CrabNebula Cloud
uses: crabnebula-dev/cloud-release@v0.1.0
with:
command: release upload ${{ env.CN_APP_SLUG }} "${{ needs.draft.outputs.tag_name }}" --framework tauri
api-key: ${{ secrets.CN_API_KEY }}
# publish:
# runs-on: ubuntu-latest
# needs: [draft, build]
# steps:
# - uses: actions/checkout@v4
# - name: Publish release
# uses: crabnebula-dev/cloud-release@v0.1.0
# with:
# command: release publish ${{ env.CN_APP_SLUG }} "${{ needs.draft.outputs.tag_name }}" --framework tauri
# api-key: ${{ secrets.CN_API_KEY }}