-
Notifications
You must be signed in to change notification settings - Fork 125
Adds workflows to create ion-java prerelease on GitHub. #452
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
Merged
Merged
Changes from all commits
Commits
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
74 changes: 74 additions & 0 deletions
74
.github/workflows/create-gitHub-prerelease-after-fast-forward-check.yml
This file contains hidden or 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,74 @@ | ||
| name: Create GitHub prerelease after fast-forward check | ||
| on: | ||
| pull_request: | ||
| types: | ||
| - closed | ||
|
|
||
| jobs: | ||
| check-version-change: | ||
| if: github.event.pull_request.merged == true | ||
| name: check-version-change | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| output1: ${{ steps.check-version-change.outputs.result }} | ||
| steps: | ||
| - name: Checkout the current repository master branch | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: amzn/ion-java | ||
| ref: master | ||
| fetch-depth: 2 | ||
| path: ion-java-current | ||
|
|
||
| - name: Check whether the pull request contains version number bump | ||
| id: check-version-change | ||
| run: | | ||
| cd ion-java-current | ||
| versionNew=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
| git reset --hard HEAD^ | ||
| versionPrevious=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
| if [[ $versionNew != $versionPrevious ]]; then echo "::set-output name=result::pass"; else echo "::set-output name=result::failed"; fi | ||
|
|
||
| prerelease: | ||
| name: prerelease | ||
| needs: check-version-change | ||
| if: ${{ needs.check-version-change.outputs.output1 == 'pass' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Access to the incoming release | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: amzn/ion-java | ||
| path: current_release | ||
|
|
||
| - name: Build ion-java | ||
| run: | | ||
| cd current_release | ||
| mvn clean install -DskipTests | ||
|
|
||
| - name: Get the parameters of executable jar | ||
| run: | | ||
| cd current_release/target | ||
| echo "path=$(readlink -f $(ls *.jar))" >> $GITHUB_ENV | ||
| echo "file_name=$(ls *.jar)" >> $GITHUB_ENV | ||
| cd .. && echo "version_number=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | ||
|
|
||
| - name: Create new release | ||
| id: create_new_release | ||
| uses: actions/create-release@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| tag_name: v${{ env.version_number }} | ||
| release_name: v${{ env.version_number }} | ||
| prerelease: true | ||
|
|
||
| - name: Upload release asset | ||
| uses: actions/upload-release-asset@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| upload_url: ${{ steps.create_new_release.outputs.upload_url }} | ||
| asset_path: ${{ env.path }} | ||
| asset_name: ${{ env.file_name }} | ||
| asset_content_type: application/zip | ||
This file contains hidden or 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,91 @@ | ||
| name: Version-bump-and-fast-forward-check | ||
| on: [pull_request] | ||
|
|
||
| jobs: | ||
| check-version-bump: | ||
| name: check-version-bump | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| output1: ${{ steps.check-version-change.outputs.result }} | ||
| steps: | ||
| - name: Switch to the branch of the pull request | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| path: ion-java-new | ||
|
|
||
| - name: Checkout the current repository master branch | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: amzn/ion-java | ||
| ref: master | ||
| path: ion-java-current | ||
|
|
||
| - name: Check whether the pull request contains version number bump | ||
| id: check-version-change | ||
| run: | | ||
| cd /home/runner/work/ion-java/ion-java/ion-java-new | ||
| versionNew=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
| commitID=$(git rev-parse HEAD) | ||
| cd /home/runner/work/ion-java/ion-java/ion-java-current | ||
| versionCurrent=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
| if [[ $versionNew != $versionCurrent ]]; then echo "::set-output name=result::pass"; else echo "::set-output name=result::failed"; fi | ||
|
|
||
| fast-forward-check: | ||
| needs: check-version-bump | ||
| name: fast-forward-check | ||
| if: ${{ needs.check-version-bump.outputs.output1 == 'pass' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Access to the last release | ||
| uses: oprypin/find-latest-tag@v1 | ||
| id: check_last_release | ||
| with: | ||
| repository: amzn/ion-java | ||
| releases-only: true | ||
|
|
||
| - name: Checkout the last release | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: amzn/ion-java | ||
| ref: ${{ steps.check_last_release.outputs.tag }} | ||
| path: last-release | ||
|
|
||
| - name: Get the commit id of the last release | ||
| run: | | ||
| cd last-release | ||
| echo "last_release_commit_id=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
|
|
||
| - name: Access to the incoming release | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: amzn/ion-java | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| path: ion-java-new | ||
|
|
||
| - name: Get the commit id of the incoming release | ||
| run: | | ||
| cd ion-java-new | ||
| echo "current_release_commit_id=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
| echo $(git rev-parse HEAD) | ||
|
|
||
| - name: Check whether the incoming release is fast-forward compared to the last release | ||
| run: | | ||
| cd ion-java-new | ||
| if git merge-base --is-ancestor ${{env.last_release_commit_id}} ${{env.current_release_commit_id}}; then echo "Trigger github release"; else exit 1; fi | ||
|
|
||
| - name: comment | ||
| if: ${{ success() }} | ||
| uses: peter-evans/create-or-update-comment@v2 | ||
| with: | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| body: | | ||
| This PR passes version bump check and fast-forward check, please double check the version number and merge this PR. After merging this PR, "Create gitHub prerelease after fast-forward check" workflow will be automatically triggered to create prerelease. | ||
|
|
||
| - name: comment | ||
| if: ${{ failure() }} | ||
| uses: peter-evans/create-or-update-comment@v2 | ||
| with: | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| body: | | ||
| This PR is not fast-forward compared to the last release, please check. |
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.
Can we verify in this workflow that no release for this version already exists? That would ensure that we don't accidentally create a new release without updating the version.
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.