petermr / ami3

Integration of cephis and normami code into a single base. Tests will be slimmed down
Apache License 2.0
17 stars 5 forks source link

Publish GitHub Release from `release.bash` script #55

Closed remkop closed 4 years ago

remkop commented 4 years ago

See if it is feasible/what is involved to publish a GitHub Release from the release.bash script.

That would make the release.bash script a true "one push" button that does the full release all the way up to publishing the distribution zip with ami binaries to GitHub Packages.

This likely involves making a curl call to the GitHub REST API.

Release Notes are an open issue here.

Now that we have more formal releases, I think it makes sense for each release to have release notes. This could be as simple as a summary and a list of issues fixed.

In the picocli project I track all changes in GitHub issues and group them in "Milestones" that correspond to releases. I have a separate RELEASE_NOTES.md file in the project where I write a post for each release. This is quite a lot of work, we can be less formal, but some release notes would be nice and we should think about where to store them.

remkop commented 4 years ago

Looks like there is a GitHub Action workflow that automatically creates a GitHub Release when a tag is pushed whose tag name starts with 'v': https://github.com/actions/create-release

This may be simplest: no need to modify the release.bash script. Regarding Release Notes: there is a body_path parameter that can be pointed to a RELEASE_NOTES.md file.


Alternatively, we can use the GitHub REST API: https://developer.github.com/v3/repos/releases/#input

The JSON to send looks fairly straightforward:

{
  "tag_name": "v1.0.0",
  "target_commitish": "master",
  "name": "v1.0.0",
  "body": "Description of the release",
  "draft": false,
  "prerelease": false
}

The authentication may be an issue when calling the REST API; we would need to specify a token. We may be able to get this from the git config (see this example).

Example curl command:

curl -v -s \
  -H "Authorization: token xxxxxxxxx" \
  -H "Content-Type:application/json" \
  "https://api.github.com/repos/:owner/:repo/releases" \
  -d '{ "user" : { "email" : "XXXXXXX", "password" : "XXXXX"}, "tag_name": "1.2.1", "target_commitish": "master", "name": "1234", "body": "Release of version 1234", "draft": false, "prerelease": false}'
remkop commented 4 years ago

Example output:

remko@LAPTOP-7EO0MTL0:/mnt/c/Users/remko/IdeaProjects/ami3a/ami3$ time ./release.bash
Releasing v2020.07.27_02.23.15
Checking for uncommitted changes...
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.contentmine:ami3 >------------------------
[INFO] Building ami3 2020.07.27_01.47-NEXT-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-scm-plugin:1.11.2:check-local-modification (default-cli) @ ami3 ---
[INFO] Executing: /bin/sh -c cd '/mnt/c/Users/remko/IdeaProjects/ami3a/ami3' && 'git' 'rev-parse' '--show-prefix'
[INFO] Working directory: /mnt/c/Users/remko/IdeaProjects/ami3a/ami3
[INFO] Executing: /bin/sh -c cd '/mnt/c/Users/remko/IdeaProjects/ami3a/ami3' && 'git' 'status' '--porcelain' '.'
[INFO] Working directory: /mnt/c/Users/remko/IdeaProjects/ami3a/ami3
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  42.919 s
[INFO] Finished at: 2020-07-27T11:24:00+09:00
[INFO] ------------------------------------------------------------------------
... OK. The workspace is clean.
Checking Release Notes for this release (RELEASE-NOTES-NEXT.md)...
... OK. Release Notes exist.
Prepending RELEASE-NOTES-NEXT.md to RELEASE-NOTES.md...
... Updated RELEASE-NOTES.md OK.
Updating release version in pom.xml to 2020.07.27_02.23.15...
Committing pom.xml and RELEASE-NOTES.md...
warning: LF will be replaced by CRLF in RELEASE-NOTES.md.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in RELEASE-NOTES.md.
The file will have its original line endings in your working directory.
... Committed OK.
Tagging last commit...
... Tagged last commit OK.

Preparing for next development cycle...
Resetting RELEASE-NOTES-NEXT.md to template...
Updating version in pom.xml to v2020.07.27_02.23-NEXT-SNAPSHOT...
Committing pom.xml and RELEASE-NOTES-NEXT.md...
warning: LF will be replaced by CRLF in RELEASE-NOTES-NEXT.md.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in RELEASE-NOTES-NEXT.md.
The file will have its original line endings in your working directory.
... Committed SNAPSHOT version and reset Release Notes OK.
Pushing changes...
... Pushed changes OK.

Release 2020.07.27_02.23.15 completed successfully.
See https://github.com/petermr/ami3/actions to monitor the GitHub Actions triggered by this tag.

real    1m10.773s
user    0m15.344s
sys     1m0.453s