Skip to content

Commit 865db81

Browse files
chore: add workflow dispatch to Release
1 parent 4045cc9 commit 865db81

File tree

1 file changed

+61
-69
lines changed

1 file changed

+61
-69
lines changed

.github/workflows/release.yml

Lines changed: 61 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
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
1+
# This workflow is manually triggered to create a new cross-platform release.
2+
name: Manually Triggered Desktop Release
33

4+
# This section defines the manual trigger for the workflow.
45
on:
5-
push:
6-
branches: [ "main" ]
7-
release:
8-
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
version-bump:
9+
description: 'The type of version bump (major, minor, or patch)'
10+
required: true
11+
default: 'patch'
12+
type: choice
13+
options:
14+
- patch
15+
- minor
16+
- major
917

1018
jobs:
19+
# This job builds the application for Windows, macOS, and Ubuntu.
1120
build-tauri:
1221
runs-on: ${{ matrix.os }}
1322
strategy:
@@ -17,7 +26,7 @@ jobs:
1726

1827
steps:
1928
- name: Checkout repository
20-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
2130

2231
- name: Setup Node.js
2332
uses: actions/setup-node@v4
@@ -33,46 +42,32 @@ jobs:
3342

3443
- name: Install Dependencies
3544
run: npm install
36-
shell: bash
3745

3846
- name: Install Tauri CLI and API
3947
run: |
4048
npm install -g @tauri-apps/cli
4149
npm install @tauri-apps/cli @tauri-apps/api @tauri-apps/plugin-fs --save-dev
42-
shell: bash
4350
4451
- name: Run Cross-Platform Build Script
4552
run: node build-desktop.js
46-
shell: bash
4753

4854
- name: Setup Rust
4955
if: matrix.os != 'windows-latest'
5056
run: |
5157
rustup update stable
5258
rustup default stable
53-
shell: bash
5459
5560
- name: Install Linux Dependencies (Ubuntu)
5661
if: matrix.os == 'ubuntu-latest'
5762
run: |
5863
sudo apt update
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
68-
shell: bash
64+
sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev
6965
7066
- name: Install macOS Dependencies
7167
if: matrix.os == 'macos-latest'
7268
run: |
7369
brew update
7470
brew install pkg-config
75-
shell: bash
7671
7772
- name: Cache Rust Dependencies
7873
uses: Swatinem/rust-cache@v2
@@ -81,105 +76,102 @@ jobs:
8176

8277
- name: Build Tauri App
8378
run: npm run tauri build
84-
shell: bash
8579

8680
- name: Upload Tauri Build Artifacts
8781
uses: actions/upload-artifact@v4
8882
with:
8983
name: Tauri Build Artifacts (${{ matrix.os }})
90-
path: |
91-
src-tauri/target/release/bundle
84+
path: src-tauri/target/release/bundle
9285

86+
# This job creates the GitHub Release after all builds are successful.
9387
create-release:
9488
runs-on: ubuntu-latest
9589
needs: build-tauri
9690
steps:
9791
- name: Checkout repository
9892
uses: actions/checkout@v4
99-
# Fetch all history for conventional-changelog to work correctly
10093
with:
94+
# Fetch all history for the changelog generator to work correctly
10195
fetch-depth: 0
10296

103-
# Corrected action name to TriPSs/conventional-changelog-action
10497
- name: Generate Changelog
10598
id: changelog
10699
uses: TriPSs/conventional-changelog-action@v3
107100
with:
108101
github-token: ${{ secrets.GITHUB_TOKEN }}
109-
110-
- name: Download Artifacts
102+
103+
- name: Download all build artifacts
111104
uses: actions/download-artifact@v4
112105
with:
113106
path: artifacts
114107

115108
- name: Prepare Release Assets
116109
run: |
117110
mkdir -p release-assets
111+
# Move all built files (.deb, .AppImage, .msi, .dmg) into one folder
112+
# The '|| true' prevents the workflow from failing if a specific file type doesn't exist
113+
find artifacts -type f \( -name "*.deb" -o -name "*.AppImage" -o -name "*.msi" -o -name "*.dmg" \) -exec cp {} release-assets/ \; || true
118114
119-
# For Ubuntu (Linux)
120-
if [ -d "artifacts/Tauri Build Artifacts (ubuntu-latest)/deb" ]; then
121-
cp artifacts/Tauri\ Build\ Artifacts\ \(ubuntu-latest\)/deb/*.deb release-assets/ || true
122-
fi
123-
if [ -d "artifacts/Tauri Build Artifacts (ubuntu-latest)/appimage" ]; then
124-
cp artifacts/Tauri\ Build\ Artifacts\ \(ubuntu-latest\)/appimage/*.AppImage release-assets/ || true
125-
fi
126-
127-
# For Windows
128-
if [ -d "artifacts/Tauri Build Artifacts (windows-latest)/msi" ]; then
129-
cp artifacts/Tauri\ Build\ Artifacts\ \(windows-latest\)/msi/*.msi release-assets/ || true
130-
fi
131-
132-
# For macOS
133-
if [ -d "artifacts/Tauri Build Artifacts (macos-latest)/dmg" ]; then
134-
cp artifacts/Tauri\ Build\ Artifacts\ \(macos-latest\)/dmg/*.dmg release-assets/ || true
135-
fi
115+
# For macOS, we also zip the .app bundle for easier distribution
136116
if [ -d "artifacts/Tauri Build Artifacts (macos-latest)/app" ]; then
137117
cd artifacts/Tauri\ Build\ Artifacts\ \(macos-latest\)/app
138118
for app in *.app; do
139119
zip -r "../../../release-assets/${app%.app}.zip" "$app"
140120
done
141-
cd - || exit
121+
cd -
142122
fi
143123
144-
ls -la release-assets/
145-
shell: bash
124+
echo "Prepared release assets:"
125+
ls -l release-assets/
146126
147127
- name: Install GitHub CLI
148128
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
129+
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
130+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
131+
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
132+
&& 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 \
133+
&& sudo apt update \
134+
&& sudo apt install gh -y
135+
136+
- name: Determine New Version and Create GitHub Release
156137
env:
157138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158139
run: |
159-
# Fetch latest tag
140+
# Fetch the latest tag from the repository
160141
LATEST_TAG=$(git tag --sort=-v:refname | head -n 1)
142+
if [[ -z "$LATEST_TAG" ]]; then
143+
# If no tags exist, start from v0.0.0
144+
LATEST_TAG="v0.0.0"
145+
fi
161146
162-
# Extract major, minor, patch versions
147+
# Parse the latest tag to get major, minor, and patch numbers
163148
if [[ "$LATEST_TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
164149
MAJOR=${BASH_REMATCH[1]}
165150
MINOR=${BASH_REMATCH[2]}
166151
PATCH=${BASH_REMATCH[3]}
167152
else
168-
MAJOR=0
169-
MINOR=0
170-
PATCH=0
153+
echo "Could not parse latest tag: $LATEST_TAG. Starting from v0.1.0."
154+
MAJOR=0; MINOR=1; PATCH=0
171155
fi
172156
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`
157+
# Increment the version based on the manual input
158+
BUMP_TYPE="${{ github.event.inputs.version-bump }}"
159+
if [ "$BUMP_TYPE" == "major" ]; then
160+
MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0
161+
elif [ "$BUMP_TYPE" == "minor" ]; then
162+
MINOR=$((MINOR + 1)); PATCH=0
163+
else # Default to patch
164+
PATCH=$((PATCH + 1))
165+
fi
166+
167+
NEW_VERSION="v$MAJOR.$MINOR.$PATCH"
168+
echo "Creating new release: $NEW_VERSION"
169+
170+
# Get the release notes generated by the changelog action
178171
CHANGELOG_NOTES="${{ steps.changelog.outputs.changelog }}"
179172
180-
# Create release
173+
# Create the GitHub Release and upload all assets
181174
gh release create "$NEW_VERSION" \
182175
--title "CircuitVerse Desktop $NEW_VERSION" \
183176
--notes "$CHANGELOG_NOTES" \
184-
release-assets/*
185-
shell: bash
177+
release-assets/*

0 commit comments

Comments
 (0)