Skip to content

Commit

Permalink
Include commit info in builds created for layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rhennigan committed Nov 29, 2023
1 parent 9b394ef commit 7ebf845
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions PacletInfo.wl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PacletObject[ <|
"ReleaseDate" -> "$RELEASE_DATE$",
"ReleaseURL" -> "$RELEASE_URL$",
"ActionURL" -> "$ACTION_URL$",
"CommitURL" -> "$COMMIT_URL$",
"Loading" -> "Startup",
"PrimaryContext" -> "Wolfram`Chatbook`",
"Extensions" -> {
Expand Down
30 changes: 18 additions & 12 deletions Scripts/Common.wl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ messageString[ ___ ] := "-- Message text not found --";
(* ::Section::Closed:: *)
(*Definitions*)

$envSHA = SelectFirst[
{ Environment[ "GITHUB_SHA" ], Environment[ "BUILD_VCS_NUMBER_WolframLanguage_Paclets_Chatbook_PacChatbook" ] },
StringQ
];

$inCICD = StringQ @ $envSHA;

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*gitCommand*)
Expand All @@ -125,7 +132,7 @@ gitCommand[ cmd_ ] := gitCommand[ cmd, Directory[ ] ];
(* ::Subsection::Closed:: *)
(*releaseID*)
releaseID[ dir_ ] :=
With[ { sha = Environment[ "GITHUB_SHA" ] },
With[ { sha = $envSHA },
If[ StringQ @ sha,
sha,
gitCommand[ { "rev-parse", "HEAD" }, dir ]
Expand All @@ -135,13 +142,15 @@ releaseID[ dir_ ] :=
(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*releaseURL*)
releaseURL[ file_ ] :=
releaseURL[ file_ ] := Enclose[
Enclose @ Module[ { pac, repo, ver },
pac = PacletObject @ Flatten @ File @ file;
repo = ConfirmBy[ Environment[ "GITHUB_REPOSITORY" ], StringQ ];
ver = ConfirmBy[ pac[ "Version" ], StringQ ];
TemplateApply[ "https://github.com/`1`/releases/tag/v`2`", { repo, ver } ]
];
],
"None" &
];

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
Expand All @@ -154,13 +163,13 @@ actionURL[ ] := Enclose[
runID = cs @ Environment[ "GITHUB_RUN_ID" ];
cs @ URLBuild @ { domain, repo, "actions", "runs", runID }
],
"$ACTION_URL$" &
"None" &
];

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*updatePacletInfo*)
updatePacletInfo[ dir_ ] /; StringQ @ Environment[ "GITHUB_ACTION" ] := Enclose[
updatePacletInfo[ dir_ ] /; $inCICD := Enclose[
Module[
{ cs, file, string, id, date, url, run, cmt, new },

Expand All @@ -181,7 +190,8 @@ updatePacletInfo[ dir_ ] /; StringQ @ Environment[ "GITHUB_ACTION" ] := Enclose[
"$RELEASE_ID$" -> id,
"$RELEASE_DATE$" -> date,
"$RELEASE_URL$" -> url,
"$ACTION_URL$" -> run
"$ACTION_URL$" -> run,
"$COMMIT_URL$" -> cmt
}
];

Expand All @@ -190,6 +200,7 @@ updatePacletInfo[ dir_ ] /; StringQ @ Environment[ "GITHUB_ACTION" ] := Enclose[
Print[ " ReleaseDate: ", date ];
Print[ " ReleaseURL: ", url ];
Print[ " ActionURL: ", run ];
Print[ " CommitURL: ", cmt ];

Confirm @ WithCleanup[ BinaryWrite[ file, new ],
Close @ file
Expand Down Expand Up @@ -224,12 +235,7 @@ updateReleaseInfoCell[ dir_, url_, cmt_, run_ ] /;
];


commitURL[ sha_String ] := Enclose @ URLBuild @ {
"https://github.com",
ConfirmBy[ Environment[ "GITHUB_REPOSITORY" ], StringQ ],
"commit",
sha
};
commitURL[ sha_String ] := URLBuild @ { "https://github.com/WolframResearch/Chatbook/commit", sha };


releaseInfoCell[ release_, commit_, run_ ] := Enclose[
Expand Down

0 comments on commit 7ebf845

Please sign in to comment.