1- # Unified GitHub Actions workflow for creating a release, building multi-platform assets,
2- # and attaching them to the new release.
1+ # This workflow is triggered on pushes to the main branch and when a new release is created.
2+ name : Vue + Tauri Simulator Desktop Release
33
4- name : Unified Release and Deploy
5-
6- # This workflow is triggered manually.
7- # It is designed to be run after a series of merged Pull Requests have accumulated.
84on :
9- workflow_dispatch :
10-
11- # The permissions required for the jobs.
12- permissions :
13- contents : write # For creating releases and pushing tags/commits
14- issues : write # For managing issues and comments
15- pull-requests : write # For managing pull requests
16- id-token : write # For OIDC authentication, if needed
17-
18- jobs :
19- # 1. This job handles the release creation and versioning using semantic-release.
20- # It determines the next version, generates the changelog, and creates the
21- # new GitHub Release.
5+ push :
6+ branches : [ "main" ]
227 release :
23- name : Create Release
24- runs-on : ubuntu-latest
25- outputs :
26- new_release_published : ${{ steps.semantic.outputs.new_release_published }}
27- new_release_version : ${{ steps.semantic.outputs.new_release_version }}
28-
29- steps :
30- - name : Checkout repository
31- uses : actions/checkout@v4
32- with :
33- fetch-depth : 0 # Required for semantic-release to analyze history
34-
35- - name : Setup Node.js
36- uses : actions/setup-node@v4
37- with :
38- node-version : " lts/*"
8+ types : [created]
399
40- - name : Install semantic-release and plugins
41- run : |
42- npm init -y
43- npm install --no-save \
44- semantic-release \
45- @semantic-release/commit-analyzer \
46- @semantic-release/release-notes-generator \
47- @semantic-release/changelog \
48- @semantic-release/github \
49- @semantic-release/git \
50- conventional-changelog-conventionalcommits
51- # semantic-release-pub plugin is specific to Dart/Flutter, we will not use it here
52- # as the user's goal is a Tauri app.
53-
54- - name : Create semantic-release config file
55- run : |
56- echo '{
57- "branches": ["main"],
58- "plugins": [
59- ["@semantic-release/commit-analyzer", {
60- "preset": "conventionalcommits"
61- }],
62- ["@semantic-release/release-notes-generator", {
63- "preset": "conventionalcommits"
64- }],
65- ["@semantic-release/changelog", {
66- "changelogFile": "CHANGELOG.md"
67- }],
68- ["@semantic-release/git", {
69- "assets": ["CHANGELOG.md"],
70- "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
71- }],
72- ["@semantic-release/github", {
73- "assets": []
74- }]
75- ]
76- }' > .releaserc.json
77-
78- - name : Run Semantic Release
79- id : semantic
80- env :
81- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82- run : npx semantic-release
83-
84- # 2. This job builds the Tauri application for multiple operating systems in parallel.
85- # It depends on the 'release' job and only runs if a new release was published.
86- build_assets :
87- name : Build Multi-Platform Assets
88- needs : release
89- if : needs.release.outputs.new_release_published == 'true'
10+ jobs :
11+ build-tauri :
9012 runs-on : ${{ matrix.os }}
9113 strategy :
9214 fail-fast : false
9517
9618 steps :
9719 - name : Checkout repository
98- uses : actions/checkout@v4
99- with :
100- ref : main # Ensure we are building the latest code from the main branch
20+ uses : actions/checkout@v3
10121
10222 - name : Setup Node.js
10323 uses : actions/setup-node@v4
@@ -121,6 +41,10 @@ jobs:
12141 npm install @tauri-apps/cli @tauri-apps/api @tauri-apps/plugin-fs --save-dev
12242 shell : bash
12343
44+ - name : Run Cross-Platform Build Script
45+ run : node build-desktop.js
46+ shell : bash
47+
12448 - name : Setup Rust
12549 if : matrix.os != 'windows-latest'
12650 run : |
@@ -132,7 +56,15 @@ jobs:
13256 if : matrix.os == 'ubuntu-latest'
13357 run : |
13458 sudo apt update
135- sudo apt install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev
59+ sudo apt install libwebkit2gtk-4.1-dev \
60+ build-essential \
61+ curl \
62+ wget \
63+ file \
64+ libxdo-dev \
65+ libssl-dev \
66+ libayatana-appindicator3-dev \
67+ librsvg2-dev
13668 shell : bash
13769
13870 - name : Install macOS Dependencies
@@ -158,16 +90,24 @@ jobs:
15890 path : |
15991 src-tauri/target/release/bundle
16092
161- # 3. This final job downloads all the built assets and uploads them to the
162- # GitHub Release that was created in the first job.
163- upload_release_assets :
164- name : Upload to Release
93+ create-release :
16594 runs-on : ubuntu-latest
166- needs : [release, build_assets]
167- if : needs.release.outputs.new_release_published == 'true'
168-
95+ needs : build-tauri
16996 steps :
170- - name : Download all build artifacts
97+ - name : Checkout repository
98+ uses : actions/checkout@v4
99+ # Fetch all history for conventional-changelog to work correctly
100+ with :
101+ fetch-depth : 0
102+
103+ # Corrected action name to TriPSs/conventional-changelog-action
104+ - name : Generate Changelog
105+ id : changelog
106+ uses : TriPSs/conventional-changelog-action@v3
107+ with :
108+ github-token : ${{ secrets.GITHUB_TOKEN }}
109+
110+ - name : Download Artifacts
171111 uses : actions/download-artifact@v4
172112 with :
173113 path : artifacts
@@ -203,15 +143,43 @@ jobs:
203143
204144 ls -la release-assets/
205145 shell : bash
206-
207- - name : Upload assets to GitHub Release
208- uses : softprops/action-gh-release@v2
146+
147+ - name : Install GitHub CLI
148+ run : |
149+ curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
150+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
151+ sudo apt update
152+ sudo apt install gh -y
153+ shell : bash
154+
155+ - name : Auto-increment version and create GitHub Release
209156 env :
210157 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
211- with :
212- files : |
158+ run : |
159+ # Fetch latest tag
160+ LATEST_TAG=$(git tag --sort=-v:refname | head -n 1)
161+
162+ # Extract major, minor, patch versions
163+ if [[ "$LATEST_TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
164+ MAJOR=${BASH_REMATCH[1]}
165+ MINOR=${BASH_REMATCH[2]}
166+ PATCH=${BASH_REMATCH[3]}
167+ else
168+ MAJOR=0
169+ MINOR=0
170+ PATCH=0
171+ fi
172+
173+ # Increment patch version
174+ NEW_VERSION="v$MAJOR.$MINOR.$((PATCH + 1))"
175+
176+ # Use the generated changelog as the release notes
177+ # The `changelog` step's output is accessed via `steps.changelog.outputs.changelog`
178+ CHANGELOG_NOTES="${{ steps.changelog.outputs.changelog }}"
179+
180+ # Create release
181+ gh release create "$NEW_VERSION" \
182+ --title "CircuitVerse Desktop $NEW_VERSION" \
183+ --notes "$CHANGELOG_NOTES" \
213184 release-assets/*
214- tag_name : v${{ needs.release.outputs.new_release_version }}
215- token : ${{ secrets.GITHUB_TOKEN }}
216- draft : false
217- prerelease : false
185+ shell : bash
0 commit comments