-
Notifications
You must be signed in to change notification settings - Fork 0
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
AJ-1095: Publish Library and CLI #3
Merged
Merged
Changes from 74 commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
c2fe637
First pass at enabling publish
snf2ye f9839c5
Add readme for publishing process
snf2ye c166dec
Add publishing to gradle and GHA
snf2ye d51d973
working local publish
snf2ye cb15888
Update name for package
snf2ye d18a403
Ensure git properties is correctly generated
snf2ye 5b5ec0c
Update name
snf2ye 841311b
Publish CLI to artifactory
snf2ye b71b879
Remaining TODO
snf2ye 8eb9e51
undo downgrading gradle
snf2ye adc0d9b
Add import from library code
snf2ye a40b1d1
Update name to action
snf2ye e4f9313
Upgrade artifactory; set git properties config for CLI
snf2ye 28bea6e
Add instructions for cli upgrade
snf2ye 9231398
Add comments
snf2ye b2233d5
Use re-usable GHA workflows instead of dispatch
snf2ye d464abd
PR Review
snf2ye 4070044
Add alias command
snf2ye 40e1d56
test out new GHA
snf2ye 26576f1
Add as release branch for testing
snf2ye 119d925
try pattern
snf2ye e55b4e7
add slash
snf2ye 7a1ad3e
bump 0.4.0
ae46970
Pull version from git config
snf2ye 4404848
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 2d1b752
Remove -SNAPSHOT from version
snf2ye 17897c0
revert to v3
snf2ye 74ae428
Updated main class declaration and add ability to run cli
snf2ye cae1cb6
Try adding automatic creation of release with CLI jar
snf2ye 129cd0f
[undo before merge] add release job to tag action just for testing
snf2ye 302b5ee
bump 0.4.0
ef6e5a2
test
snf2ye d536fc8
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 2d7ca3d
test
snf2ye ff47321
bump 0.5.0
ba39847
Revert "bump 0.5.0"
snf2ye d59de79
try using workspace path
snf2ye bb9c1c5
test
snf2ye a4a819d
bump 0.5.0
a53412b
test
snf2ye 93d6baf
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 217dc79
bump 0.6.0
c9db1cd
try again
snf2ye 14d5829
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye a4fccc4
variable name
snf2ye b381f4c
bump 0.7.0
73f7b2f
test
snf2ye 2bf80a7
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 08b2666
bump 0.8.0
d63164e
try release upgrade command
snf2ye 77de92a
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye aa6687e
bump 0.9.0
4ea5b58
create and upload files and generate notes
snf2ye c70964e
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 032fe8c
bump 0.10.0
1886829
remove github workspace
snf2ye b90a8c0
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 1ce9fa0
bump 0.11.0
162b07f
test
snf2ye d91b74b
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 0e1c911
bump 0.12.0
62d3db4
make sure we're checking out the tagged
snf2ye f67f49c
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye d98af31
fix formatting
snf2ye 1aee392
bump 0.13.0
234c01d
Final changes to github actions; revert settings.gradle
snf2ye 38d94a4
Merge branch 'sh-aj-1095-publilsh' of https://github.com/DataBiospher…
snf2ye 172505f
Update cli release related code
snf2ye 213eb49
Update readme for CLI release
snf2ye 8cfff95
Fix spotbugs
snf2ye c100b79
Update README.md and include distribution in the release
snf2ye d0f51c9
pass output from tag to release-cli
snf2ye 51e3b45
spotbugs fix
snf2ye a50708f
Add comment
snf2ye 0d7456e
Add test coverage
snf2ye 96d1b03
Add more info to readme on how to use published resources
snf2ye f8f2edd
Update GHA - fix inputs, outputs
snf2ye 2d82292
UNDO BEFORE MERGE - undo main
snf2ye 25809fc
Consolidate slack notifications and have single gradlew build call
snf2ye 56f6a5b
add workflow dispatch
snf2ye 1304203
add back ref
snf2ye 2ceffbe
Need secrets inherit in order use secrets in called workflow
snf2ye ae5ccc7
test full workflow - undo before merge
snf2ye 532fb34
Revert "test full workflow - undo before merge"
snf2ye 56530d6
PR Review: Update GitConfiguration
snf2ye 7af365e
PR Review: Remove workflow_dispatch trigger, Update required secrets
snf2ye 68271bd
PR Review: Updated command
snf2ye 0fa541f
PR Review: Remove artifact group
snf2ye 083145d
update formatting
snf2ye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,42 @@ | ||
name: Create Github Release with CLI Jar and Distribution | ||
on: | ||
workflow_call: | ||
inputs: | ||
tag: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
release-job: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ needs.tag-job.outputs.tag }} | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
- name: Build jar with latest tagged version | ||
run: | | ||
./gradlew --build-cache :cli:jar | ||
./gradlew --build-cache :cli:assembleDist | ||
snf2ye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Create tagged release with CLI jar | ||
run: gh release create ${{ needs.tag-job.outputs.tag }} 'cli/build/libs/java-pfb-cli-${{ needs.tag-job.outputs.tag }}.jar' 'cli/build/distributions/cli-${{ needs.tag-job.outputs.tag }}.zip' --generate-notes --verify-tag | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
- name: Notify slack on failure | ||
snf2ye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: broadinstitute/action-slack@v3.8.0 | ||
if: failure() | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
with: | ||
channel: '#dsp-analysis-journeys-alerts' | ||
status: failure | ||
author_name: Create Github Release with CLI Jar | ||
fields: job | ||
text: 'Publish failed :sadpanda:' | ||
username: 'Java-PFB GitHub Action' |
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
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
4 changes: 4 additions & 0 deletions
4
buildSrc/src/main/groovy/bio.terra.pfb.java-application-conventions.gradle
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,4 @@ | ||
plugins { | ||
id 'bio.terra.pfb.java-common-conventions' | ||
id 'application' | ||
} |
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 |
---|---|---|
@@ -1,14 +1,74 @@ | ||
Current usage of CLI: | ||
First, run "jar" gradle task in cli project. | ||
Java PFB CLI | ||
=== | ||
|
||
## Available Commands | ||
- hello | ||
- getNumber5 | ||
- --version | ||
- --help | ||
|
||
## Local Run and Development | ||
|
||
### Option 1 - Run via Gradle (Suggested workflow) | ||
|
||
Run the following command to build the library and CLI jar and execute a command: | ||
```shell | ||
./gradlew run --args=<command> | ||
``` | ||
|
||
### Option 2: Assemble distribution zip and run | ||
Run the following command to build the library and CLI jar: | ||
```shell | ||
./gradlew :cli:assembleDist | ||
``` | ||
Unzip the distribution | ||
```shell | ||
unzip cli/build/distributions/cli-<VERSION>.zip | ||
``` | ||
Run commands | ||
```shell | ||
./cli-<VERSION>/bin/cli <command> | ||
``` | ||
|
||
### Option 3: Build and run jar | ||
Run the following command to build the library and CLI jar: | ||
```shell | ||
./gradlew :cli:jar | ||
snf2ye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
Then, you can use the CLI with the following command: | ||
```shell | ||
java -cp "cli/build/libs/java-pfb-cli.jar" bio.terra.pfb.JavaPfbCommand <command> | ||
java -cp "cli/build/libs/java-pfb-cli-<VERSION>.jar" bio.terra.pfb.JavaPfbCommand <command> | ||
``` | ||
Available Commands: | ||
- hello | ||
- --version | ||
- --help | ||
An alias can be created to simplify this command: | ||
```shell | ||
alias pfb='java -cp "cli/build/libs/java-pfb-cli-<VERSION>.jar" bio.terra.pfb.JavaPfbCommand' | ||
``` | ||
Example usage of the alias: | ||
```shell | ||
pfb --version | ||
``` | ||
|
||
# Download and run the CLI | ||
## Option 1 - Run from Jar Downloaded from Github Release | ||
1) Download Jar from latest Github release. | ||
2) Note the location of the downloaded jar and run the jar with the following command: | ||
```shell | ||
java -cp "<PATH-TO-JAR>" bio.terra.pfb.JavaPfbCommand <command> | ||
``` | ||
## Option 2 - Run from Distribution Downloaded from Github Release | ||
1) Download Distribution zip from latest Github release. | ||
2) Unzip the distribution | ||
```shell | ||
unzip <PATH-TO-ZIP>/cli-<VERSION>.zip | ||
``` | ||
3) Note the location of the unzipped distribution and run the CLI with the following command: | ||
```shell | ||
./cli-<VERSION>/bin/cli --version | ||
``` | ||
|
||
## Upgrade the CLI | ||
|
||
Github release containing the CLI jar is automatically generated via Github actions when a change is pushed to main. | ||
|
||
|
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,10 @@ | ||
def artifactGroup = "${group}.javapfb.cli" | ||
snf2ye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// see https://github.com/n0mer/gradle-git-properties | ||
gitProperties { | ||
keys = [] | ||
customProperty('javapfb.cli.version.gitTag', { it.describe(tags: true) }) | ||
customProperty('javapfb.cli.version.gitHash', { it.head().abbreviatedId }) | ||
customProperty('javapfb.cli.version.github', { "https://github.com/DataBiosphere/java-pfb/tree/${it.describe(tags: true)}" }) | ||
customProperty('javapfb.cli.version.build', version) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong but I seem to recall it was done using
workflow-dispatch
because otherwise the tag job would trigger another CI build and the you'd end up with an infinite loopThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling that out -- I'd like to continue to use the "workflow-call" because it's the new standard and workflow-dispatch introduces its own complications. (The tag action won't necessarily complete before the following publish actions, it's only dispatched.) So, I've added an ignore path on "settings.gradle" so that the action won't be triggered when there are only changes to settings.gradle. https://github.com/DataBiosphere/java-pfb/pull/3/files#diff-bc668a2c9f2299cef15b222055b4b4d5311646caec2e7610e540cee18ae9b948R8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I missed the
paths-ignore
change above. I'm torn on which is the better approach; I don't like workflow-dispatch that much but way means that thepaths-ignore
setting depends on the regex intag.yml
and there's no way to directly link the two together. Still it'd be nice to have a single common way to do this across all our repos so if this is agreed to be better we should promote it elsewhere too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I do see that there are some cons to the workflow_call method; I would say that workflow_call is the better method and think that we should convert to this across DSP. If at all possible, I try to avoid using third-party GH actions. In order to use workflow_dispatch to trigger another action, we use a forked GHA (https://github.com/broadinstitute/workflow-dispatch). Workflow_call method is a native way to do this with GHA that also has a few good built-in features. One big one is the ability to have the workflow diagram automatically capture the reusable workflows.
I've already been making the switch where it makes sense in TDR (DataBiosphere/jade-data-repo#1404). Once we land on a good setup, I'll make these changes in the java template project.