Skip to content

App Release Flow

App Release Flow #39

Workflow file for this run

name: App Release Flow
on:
push:
tags:
- "v*"
workflow_dispatch:
branches:
- main
inputs:
draft:
description: is a draft release?
type: choice
options:
- "yes"
- "no"
- "no-release"
default: "yes"
prerelease:
description: is a prerelease?
type: choice
options:
- "yes"
- "no"
default: "yes"
env:
CI: true
CI_RELEASE: true
jobs:
build:
if: inputs.draft == 'no-release'
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
artifact_path: target/release/bundle/dmg/*.dmg
- platform: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_path: target/release/bundle/rpm/*.rpm
- platform: windows-latest
target: x86_64-pc-windows-msvc
artifact_path: target/release/bundle/msi/*.msi
steps:
- uses: actions/checkout@v4
- name: Rewrite submodule URLs and checkout submodules
if: matrix.platform != 'windows-latest'
shell: bash
run: |
git config --global url.https://gh_pat:${{ secrets.GH_PAT }}@github.com/.insteadOf [email protected]:
git submodule sync --recursive
git submodule update --init --recursive --depth=1
git config --global --unset url.https://gh_pat:${{ secrets.GH_PAT }}@github.com/.insteadOf
- name: Setup Git with PAT
if: matrix.platform == 'windows-latest'
shell: pwsh
run: |
git config --global url.https://gh_pat:${{ secrets.GH_PAT }}@github.com/.insteadOf [email protected]:
git submodule sync --recursive
git submodule update --init --recursive --depth=1
git config --global --unset url.https://gh_pat:${{ secrets.GH_PAT }}@github.com/.insteadOf
- uses: ./.github/actions/setup-rust
with:
platform: ${{ matrix.platform }}
target: ${{ matrix.target }}
- name: setup-node
uses: ./.github/actions/setup-node
with:
platform: ${{ matrix.platform }}
- name: clean
shell: bash
run: |
make ci.clean
- name: Build Application
run: |
cargo tauri build --features native
- name: Archive Artifacts
run: |
mkdir -p artifacts
cp ${{ matrix.artifact_path }} artifacts/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.platform }}-${{ matrix.target }}
path: artifacts/
create-release:
if: inputs.draft != 'no-release'
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
VERSION: ${{ steps.get_version.outputs.version }}
TAG_BUILD: ${{ steps.get_version.outputs.tag_build }}
RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }}
steps:
- uses: actions/checkout@v4
- name: Set VERSION environment variable
id: get_version
run: |
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "VERSION=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
echo "TAG_BUILD=true" >> $GITHUB_OUTPUT
else
git fetch --tags
TAGS=$(git tag --list 'v0.*.*')
MAX_VERSION="0.0.0"
for TAG in $TAGS; do
VERSION=${TAG#v}
if [ "$(printf '%s\n' "$VERSION" "$MAX_VERSION" | sort -V | head -n1)" = "$MAX_VERSION" ]; then
MAX_VERSION=$VERSION
fi
done
# Increment the maximum version
NEW_VERSION=$(echo ${MAX_VERSION} | awk -F. '{$3 = $3 + 1; print}' OFS=.)
# Set the VERSION environment variable
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "TAG_BUILD=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ steps.get_version.outputs.version }}"
name: "Bodhi v${{ steps.get_version.outputs.version }}"
body: "See the assets to download this version and install."
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}
publish:
if: inputs.draft != 'no-release'
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.platform }}
steps:
- name: envs
run: |
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
echo RUN_URL=${RUN_URL} >> $GITHUB_ENV
echo TARGET=${{ matrix.target }} >> $GITHUB_ENV
echo VERSION=${{ needs.create-release.outputs.VERSION }} >> $GITHUB_ENV
echo TAG_BUILD=${{ needs.create-release.outputs.TAG_BUILD }} >> $GITHUB_ENV
echo RELEASE_UPLOAD_ID=${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }} >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: setup
uses: ./.github/actions/setup
with:
GH_PAT: ${{ secrets.GH_PAT }}
platform: ${{ matrix.platform }}
- uses: ./.github/actions/setup-rust
with:
platform: ${{ matrix.platform }}
- uses: ./.github/actions/setup-node
- name: clean
run: |
make ci.clean
- name: Update version in Cargo.toml files
run: |
make ci.update-version VERSION=${{ env.VERSION }}
- name: tauri-action
id: tauri-action
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEXT_PUBLIC_API_BASE_URL: "/"
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_PRIVATE_KEY: "${{ secrets.TAURI_PRIVATE_KEY }}"
with:
projectPath: app
appName: Bodhi
releaseId: ${{ env.RELEASE_UPLOAD_ID }}
args: "--target ${{ matrix.target }}"
- name: Update Homebrew Formula
if: matrix.target == 'aarch64-apple-darwin'
uses: ./.github/actions/homebrew
with:
access_token: ${{ secrets.GH_PAT }}
artifact_paths: ${{ steps.tauri-action.outputs.artifactPaths }}
- name: Find the next version
if: env.TAG_BUILD == 'false'
run: |
NEXT_VERSION=$(echo ${{ env.VERSION }} | awk -F. '{$3 = $3 + 1; print}' OFS=.)
NEXT_VERSION="${NEXT_VERSION}-dev"
echo NEXT_VERSION=${NEXT_VERSION} >> $GITHUB_ENV
- name: Update version to next dev version
if: env.TAG_BUILD == 'false'
run: |
make ci.update-version VERSION=${{ env.NEXT_VERSION }}
- name: Commit and push changes
if: env.TAG_BUILD == 'false'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git add crates/*/Cargo.toml crates/bodhi/src-tauri/Cargo.toml
git commit -m "[Github Bot] Bump up minor version to ${NEXT_VERSION}, url: ${{ env.RUN_URL }}"
- name: Update update.json for aarch64-apple-darwin
if: matrix.target == 'aarch64-apple-darwin' && env.TAG_BUILD == 'false'
run: |
LATEST_JSON=$(cat latest.json)
VERSION=$(echo "$LATEST_JSON" | jq -r '.version')
PUB_DATE=$(echo "$LATEST_JSON" | jq -r '.pub_date')
DARWIN_AARCH64=$(echo "$LATEST_JSON" | jq -r '.platforms."darwin-aarch64"')
# Update update.json with the extracted values
jq --arg VERSION "$VERSION" \
--arg PUB_DATE "$PUB_DATE" \
--argjson DARWIN_AARCH64 "$DARWIN_AARCH64" \
'.version = $VERSION | .pub_date = $PUB_DATE | .platforms."darwin-aarch64" = $DARWIN_AARCH64' \
update.json > tmp.json && mv tmp.json update.json
# Commit and push the updated update.json file
git add update.json
git commit -m "[Github Bot][${{ env.VERSION }}] Update update.json for aarch64-apple-darwin version, url: ${{ env.RUN_URL }}"
- name: Push the changes
if: env.TAG_BUILD == 'false'
run: |
git pull origin main --rebase
git push origin main