Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve scripts/generate-release-changelog-links.hs #6119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ There's a script (`scripts/generate-release-changelog-links.hs`) that generates
> example usage (be sure to run `cabal build all` at least once beforehand):
> ```
> $ nix build .#project.x86_64-linux.plan-nix.json
> $ ./scripts/generate-release-changelog-links.hs result-json $GITHUB_API_TOKEN
> $ ./scripts/generate-release-changelog-links.hs result-json $GITHUB_API_TOKEN -o links.md
> ```
> for more information, including how to generate / retrieve a GitHub API token, use `./scripts/generate-release-changelog-links.hs --help`
14 changes: 8 additions & 6 deletions scripts/generate-release-changelog-links.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S cabal run --verbose=1 --index-state=2024-04-09T14:49:48Z
#!/usr/bin/env -S cabal --verbose=1 --index-state=2024-04-09T14:49:48Z run --
{- cabal:
build-depends:
base,
Expand Down Expand Up @@ -47,6 +47,7 @@ import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import qualified Data.Text.Encoding as Text
import Data.Version
import qualified GitHub
Expand All @@ -65,10 +66,11 @@ import Turtle
main :: IO ()
main = sh do

(planJsonFilePath, gitHubAccessToken) <-
options generateReleaseChangelogLinksDescription do
(,) <$> argPath "plan_json_path" "Path of the plan.json file"
<*> fmap (GitHubAccessToken . Text.encodeUtf8) (argText "github_access_token" "GitHub personal access token")
(outputPath, planJsonFilePath, gitHubAccessToken) <-
options generateReleaseChangelogLinksDescription $
(,,) <$> optPath "output" 'o' "Write the generated links to OUTPUT"
<*> argPath "plan_json_path" "Path of the plan.json file"
<*> fmap (GitHubAccessToken . Text.encodeUtf8) (argText "github_access_token" "GitHub personal access token")

packagesMap <- getCHaPPackagesMap

Expand Down Expand Up @@ -97,7 +99,7 @@ main = sh do
case pandocOutput of
Left pandocError -> die $
"Failed to render markdown with error " <> Pandoc.renderError pandocError
Right res -> printf (s%"\n") res
Right res -> liftIO . Text.writeFile outputPath $ format (s%"\n") res

generateReleaseChangelogLinksDescription :: Description
generateReleaseChangelogLinksDescription = Description $
Expand Down
Loading