-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1005 from WolframResearch/feature/increment-pacle…
…t-version Automatically increment paclet version when pushing changes to main
- Loading branch information
Showing
4 changed files
with
149 additions
and
10 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
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,56 @@ | ||
name: Increment Paclet Version | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
WOLFRAMSCRIPT_ENTITLEMENTID: ${{ secrets.WOLFRAMSCRIPT_ENTITLEMENTID }} | ||
WOLFRAM_SYSTEM_ID: Linux-x86-64 | ||
UPDATE_PACLET_INFO: false | ||
|
||
jobs: | ||
IncrementVersion: | ||
name: Increment Version | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
container: | ||
image: wolframresearch/wolframengine:14.1 | ||
options: --user root | ||
|
||
steps: | ||
- name: Update Git | ||
run: | | ||
apt-get update && apt-get install software-properties-common -y | ||
add-apt-repository ppa:git-core/ppa -y | ||
apt-get update && apt-get install git -y | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure Git | ||
run: | | ||
git config --global --add safe.directory $(pwd) | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
- name: Increment Version | ||
run: wolframscript -f Scripts/IncrementPacletVersion.wls | ||
|
||
- name: Commit Changes | ||
shell: bash | ||
run: | | ||
echo "Status: $(git status --porcelain)" | ||
if [[ -n $(git status --porcelain) ]]; then | ||
git add PacletInfo.wl | ||
git commit -m "Automated: Increment paclet version" | ||
git push | ||
else | ||
echo "No changes to commit" | ||
fi |
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,76 @@ | ||
#!/usr/bin/env wolframscript | ||
|
||
BeginPackage[ "Wolfram`ChatbookScripts`" ]; | ||
|
||
If[ ! TrueQ @ $loadedDefinitions, Get @ FileNameJoin @ { DirectoryName @ $InputFileName, "Common.wl" } ]; | ||
|
||
Needs[ "Wolfram`PacletCICD`" -> "cicd`" ]; | ||
|
||
(* ::**************************************************************************************************************:: *) | ||
(* ::Section::Closed:: *) | ||
(*Definitions*) | ||
|
||
(* ::**************************************************************************************************************:: *) | ||
(* ::Subsection::Closed:: *) | ||
(*incrementPacletVersion*) | ||
(* :!CodeAnalysis::BeginBlock:: *) | ||
(* :!CodeAnalysis::Disable::SuspiciousSessionSymbol:: *) | ||
(* :!CodeAnalysis::Disable::LeakedVariable:: *) | ||
incrementPacletVersion[ dir_ ] := Enclose[ | ||
Catch @ Module[ | ||
{ cs, file, string, version, newVersion, new }, | ||
|
||
cs = ConfirmBy[ #1, StringQ, #2 ] &; | ||
file = cs[ FileNameJoin @ { dir, "PacletInfo.wl" }, "PacletInfo" ]; | ||
string = cs[ ReadString @ file, "ReadString" ]; | ||
version = cs[ PacletObject[ Flatten @ File @ dir ][ "Version" ], "Version" ]; | ||
|
||
If[ StringEndsQ[ version, "." ~~ "0".. ~~ EndOfString ], | ||
Print[ "Skipping paclet version update: ", version ]; | ||
Throw @ version | ||
]; | ||
|
||
newVersion = cs[ | ||
StringReplace[ | ||
version, | ||
"." ~~ v: DigitCharacter.. ~~ EndOfString :> "." <> ToString[ ToExpression @ v + 1 ] | ||
], | ||
"NewVersion" | ||
]; | ||
|
||
ConfirmAssert[ PacletNewerQ[ newVersion, version ], "PacletNewerQ" ]; | ||
|
||
new = cs[ | ||
StringReplace[ | ||
string, | ||
pre: ("\"Version\"" ~~ $$ws ~~ "->" ~~ $$ws) ~~ "\"" ~~ version ~~ "\"" :> | ||
pre <> "\"" <> newVersion <> "\"" | ||
], | ||
"UpdatedPacletInfo" | ||
]; | ||
|
||
Print[ "Incrementing version: ", version, " -> ", newVersion ]; | ||
Confirm[ WithCleanup[ BinaryWrite[ file, new ], Close @ file ], "WritePacletInfo" ]; | ||
|
||
ConfirmMatch[ | ||
PacletObject[ Flatten @ File @ dir ][ "Version" ], | ||
newVersion, | ||
"PacletObject" | ||
] | ||
], | ||
Function[ | ||
Print[ "::error::Failed to increment paclet version." ]; | ||
Print[ " ", ToString[ #, InputForm ] ]; | ||
If[ StringQ @ Environment[ "GITHUB_ACTION" ], Exit[ 1 ] ] | ||
] | ||
]; | ||
(* :!CodeAnalysis::EndBlock:: *) | ||
|
||
(* ::**************************************************************************************************************:: *) | ||
(* ::Section::Closed:: *) | ||
(*Run*) | ||
result = cicd`ScriptConfirmBy[ incrementPacletVersion @ $pacletDir, StringQ ]; | ||
|
||
EndPackage[ ]; | ||
|
||
Wolfram`ChatbookScripts`result |