-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,37 +35,10 @@ jobs: | |
next-release-version: ${{ steps.get-next-release.outputs.next-release-version }} | ||
next-release-git-tag: ${{ steps.get-next-release.outputs.next-release-git-tag }} | ||
next-release-notes: ${{ steps.get-next-release.outputs.next-release-notes }} | ||
prepare-commit: | ||
needs: get-next-release | ||
if: needs.get-next-release.outputs.next-release-published == 'true' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Bump Cargo.toml version | ||
run: | | ||
sed -i 's/"version": "[0-9]\+\.[0-9]\+\.[0-9]\+"/"version": "${{ needs.get-next-release.outputs.next-release-version }}"/' src-tauri/tauri.conf.json | ||
- name: Prepare commit changes | ||
id: current-commit | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
git add src-tauri/tauri.conf.json | ||
git commit -m "Bump version [skip ci]" | ||
git push --dry-run | ||
echo "last-commit-sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
- name: Show last commit SHA | ||
run: | | ||
echo "Last commit SHA: ${{ steps.current-commit.outputs.last-commit-sha }}" | ||
outputs: | ||
last-commit-sha: ${{ steps.current-commit.outputs.last-commit-sha }} | ||
|
||
build: | ||
needs: | ||
- get-next-release | ||
- prepare-commit | ||
if: needs.get-next-release.outputs.next-release-published == 'true' | ||
permissions: | ||
contents: write | ||
|
@@ -85,8 +58,6 @@ jobs: | |
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ needs.prepare-commit.outputs.last-commit-sha }} | ||
|
||
- name: Rust setup | ||
uses: dtolnay/rust-toolchain@stable | ||
|
@@ -117,6 +88,16 @@ jobs: | |
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too. | ||
run: npm install # Change this to npm, yarn or pnpm. | ||
|
||
- name: Bump tauri.config.json version | ||
run: npm run bump-tauri-version ${{ needs.get-next-release.outputs.next-release-version }} | ||
- name: Push commit | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
git add src-tauri/tauri.conf.json | ||
git commit -m "Bump version [skip ci]" | ||
git push --dry-run | ||
- name: Build the app | ||
id: tauri-action | ||
uses: tauri-apps/[email protected] | ||
|
@@ -133,13 +114,20 @@ jobs: | |
args: ${{ matrix.args }} | ||
|
||
push-changes: | ||
needs: build | ||
needs: | ||
- get-next-release | ||
- build | ||
if: success() | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ needs.prepare-commit.outputs.last-commit-sha }} | ||
- name: Push commit changes | ||
run: git push | ||
- name: Bump tauri.config.json version | ||
run: npm run bump-tauri-version ${{ needs.get-next-release.outputs.next-release-version }} | ||
- name: Push commit | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
git add src-tauri/tauri.conf.json | ||
git commit -m "Bump version [skip ci]" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { DIRNAME } from "./constants.js"; | ||
|
||
const filePath = path.resolve(DIRNAME, "../src-tauri/tauri.conf.json"); | ||
const newVersion = process.argv[2]; | ||
|
||
if (!newVersion) { | ||
console.error("Version argument is required"); | ||
process.exit(1); | ||
} | ||
|
||
// Lire le contenu du fichier tauri.conf.json | ||
const fileContent = fs.readFileSync(filePath, "utf8"); | ||
const config = JSON.parse(fileContent); | ||
const currentVersion = config.package.version; | ||
|
||
// Fonction pour comparer les versions | ||
function isVersionGreater(newVer, currentVer) { | ||
const newParts = newVer.split(".").map(Number); | ||
const currentParts = currentVer.split(".").map(Number); | ||
|
||
for (let i = 0; i < newParts.length; i++) { | ||
if (newParts[i] > currentParts[i]) return true; | ||
if (newParts[i] < currentParts[i]) return false; | ||
} | ||
return false; | ||
} | ||
|
||
if (!isVersionGreater(newVersion, currentVersion)) { | ||
console.error("New version must be greater than the current version"); | ||
process.exit(1); | ||
} | ||
|
||
const updatedContent = fileContent.replace( | ||
/"version": "\d+\.\d+\.\d+"/, | ||
`"version": "${newVersion}"` | ||
); | ||
|
||
fs.writeFileSync(filePath, updatedContent, "utf8"); | ||
console.log(`Version updated to ${newVersion}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
export const DIRNAME = path.dirname(fileURLToPath(import.meta.url)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters