Skip to content

Commit

Permalink
MAINT better build and release workflows (#58)
Browse files Browse the repository at this point in the history
* upload built artifacts

* try converting yaml array to multiline string repr

* fix invalid symbol

* test debug

* revert and try again

* re-enable for all platforms

* add commenting functionality

* test failure command

* better comments and try to fix condition

* fix invalid symbol

* fix invalid condition

* fix comment

* fix comment

* use correct sha

* improved message

* test success case

* setup release workflow

* update versioning

* msi complains about alpha/beta

* modify release workflow a bit

* modify release workflow a bit
  • Loading branch information
Charlie-XIAO authored May 14, 2024
1 parent 26b31c5 commit ef22f54
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 3 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,84 @@ jobs:
# Without specifying `tagName` and `releaseId`, tauri-action will only build the
# application without trying to upload any assets
- name: Build Deskulpt
id: build-deskulpt
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload build artifacts
id: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.platform }}
path: "${{ join(fromJSON(steps.build-deskulpt.outputs.artifactPaths), '\n') }}"

comment-success:
needs: build
if: always() && needs.build.result == 'success' && github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- name: Get short commit SHA
id: short-sha
run: |
shortsha=$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-7)
echo "sha=$shortsha" >> $GITHUB_OUTPUT
- name: Find comment
id: find-comment
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: |
.github/workflows/build.yaml
- name: Post success comment
if: "always() && (needs.build.result == 'success')"
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## ✔️ Deskulpt Built Successfully!
Deskulpt binaries have been built successfully on all supported platforms. Your pull request is in excellent shape! You may check the built Deskulpt binaries [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) and download them to test locally.
<sub> Workflow file: `.github/workflows/build.yaml`. Generated for commit: [`${{ steps.short-sha.outputs.sha }}`](https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${{ github.event.pull_request.head.sha }}). </sub>
edit-mode: replace

comment-failure:
needs: build
if: always() && needs.build.result != 'success' && github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- name: Get short commit SHA
id: short-sha
run: |
shortsha=$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-7)
echo "sha=$shortsha" >> $GITHUB_OUTPUT
- name: Find comment
id: find-comment
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: |
.github/workflows/build.yaml
- name: Post failure comment
if: "always() && (needs.build.result != 'success')"
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |-
## ❌ Failed to Build Deskulpt
There seems to be some issues with the build process for certain platforms. Please check the logs in the [failing workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details and fix the issues accordingly.
<sub> Workflow file: `.github/workflows/build.yaml`. Generated for commit: [`${{ steps.short-sha.outputs.sha }}`](https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${{ github.event.pull_request.head.sha }}). </sub>
edit-mode: replace
66 changes: 66 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release Deskulpt

on:
push:
branches:
- release
workflow_dispatch:

jobs:
publish-deskulpt:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest # Arm-based macOS (M1 and above)
args: --target aarch64-apple-darwin
- platform: macos-latest # Intel-based macOS
args: --target x86_64-apple-darwin
- platform: ubuntu-latest
args: ""
- platform: windows-latest
args: ""
runs-on: ${{ matrix.platform }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies (Ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: ./src-tauri -> target

- name: Node setup and cache
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: Install frontend dependencies
run: npm install

- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: v__VERSION__
releaseName: "Deskulpt v__VERSION__"
releaseBody: |
See the assets to download this version of Deskulpt and install.
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}
2 changes: 0 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[package]
name = "deskulpt"
version = "0.0.0"
description = "Deskulpt (Desktop + Sculpt, pronounced /'deskʌlpt/), a cross-platform desktop customization tool."
authors = ["Xinyu Li", "Yao Xiao", "Yuchen Zhou", "Frank Zhu"]
edition = "2021"

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"productName": "Deskulpt",
"version": "0.0.0",
"version": "0.0.1",
"identifier": "com.tauri.deskulpt",
"build": {
"beforeDevCommand": "npm run dev",
Expand Down

0 comments on commit ef22f54

Please sign in to comment.