Skip to content

slam

slam #34

Workflow file for this run

name: "Publish Release"
# This will trigger the action on each push to the `main` branch.
on:
push:
branches:
- main
- cn-cloud
env:
CN_ENV: qa
jobs:
check-for-version-changes:
name: Check for Version Changes
runs-on: ubuntu-latest
outputs:
should-run-next-jobs: ${{ steps.decide-to-run.outputs.run }}
version: ${{ steps.decide-to-run.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install JQ (for JSON parsing)
run: sudo apt-get install jq
- name: Check for tauri.conf.json or package.json changes
id: decide-to-run
run: |
RUN_NEXT_JOBS="false"
if [ -f "./src-tauri/tauri.conf.json" ]; then
PREV_VERSION=$(git show HEAD^:./src-tauri/tauri.conf.json | jq -r '.package.version' || echo "")
CURR_VERSION=$(jq -r '.package.version' ./src-tauri/tauri.conf.json)
elif [ -f "package.json" ]; then
PREV_VERSION=$(git show HEAD^:./package.json | jq -r '.version' || echo "")
CURR_VERSION=$(jq -r '.version' ./package.json)
fi
if [ ! -z "$PREV_VERSION" ] && [ "$PREV_VERSION" != "$CURR_VERSION" ]; then
RUN_NEXT_JOBS="true"
fi
# Check for tag pushes if no relevant files are found or version has not changed
if [ "${{ github.event_name }}" == "push" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then
RUN_NEXT_JOBS="true"
fi
echo "run=$RUN_NEXT_JOBS" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
exit 0
draft:
name: Draft Release
needs: check-for-version-changes
if: needs.check-for-version-changes.outputs.run-next-jobs == 'true'
runs-on: ubuntu-latest
steps:
- name: Create Draft Release (CrabNebula Cloud)
uses: crabnebula-dev/cloud-release@dev
id: draft
with:
command: release draft ${{ secrets.CN_APP_ID }} ${{ steps.check-for-version-changes.outputs.version }}
api-key: ${{ secrets.CN_API_KEY }}
build-and-upload:
name: Build and Upload Assets
needs: draft
permissions:
contents: write
strategy:
fail-fast: false
# This will create a job for each platform in the matrix
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
bundle-path: ./src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/tauri-cn-github-action_0.0.0_aarch64.dmg
- platform: ubuntu-latest
target: x86_64-unknown-linux-gnu
bundle-path: ./src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/deb/tauri-cn-github-action_0.0.0_amd64.deb
- platform: windows-latest
target: x86_64-pc-windows-msvc
bundle-path: ./src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/tauri-cn-github-action_0.0.0_x64_en-US.msi
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- uses: Swatinem/rust-cache@v2
- name: Install Dependencies (Ubuntu only)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: Set Rust target
run: rustup target add ${{ matrix.target }}
- name: Install Front-end Dependencies
run: npm install
- name: Build Tauri App
run: npm run tauri build -- -vv --target ${{ matrix.target }}
- name: Upload Build Artifacts (CrabNebula Cloud)
uses: crabnebula-dev/cloud-release@dev
id: upload
with:
command: release upload --file ${{matrix.bundle-path}} ${{ secrets.CN_APP_ID }} ${{ steps.check-for-version-changes.outputs.version }}
api-key: ${{ secrets.CN_API_KEY }}
publish:
name: Publish Release to CrabNebula Cloud
needs: build-and-upload
runs-on: ubuntu-latest
steps:
- uses: crabnebula-dev/cloud-release@dev
id: publish
with:
command: release publish ${{ secrets.CN_APP_ID }} ${{ steps.check-for-version-changes.outputs.version }}
api-key: ${{ secrets.CN_API_KEY }}