-
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
ci: snapshot publish workflow #5
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
081c360
ci: add snapshot publish workflow
nsenave d9063d1
ci(snapshot): labeled trigger condition
nsenave bd8e82c
ci: add skip test conditions
nsenave 348c802
ci(snapshot): remove condition on remove label
nsenave 13f5daa
build: use legacy maven hostnames by default
nsenave 7aeed67
ci(snapshot): try removing option in java action
nsenave 306d82c
chore: release version
nsenave 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Publish snapshot | ||
|
||
on: | ||
pull_request: | ||
types: [labeled] | ||
|
||
env: | ||
JAVA_VERSION: '17' | ||
|
||
jobs: | ||
|
||
check-version: | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'publish-snapshot') }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
snapshot-version: ${{ steps.version-step.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: ${{ env.JAVA_VERSION }} | ||
|
||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v3 | ||
|
||
- name: Get DDI-Lifecycle lib version | ||
id: version-step | ||
run: | | ||
./gradlew # (load the gradle wrapper, required for the get version step) | ||
echo "version=$(./gradlew :model:printVersion --console=plain -q)" >> $GITHUB_OUTPUT | ||
|
||
- name: Snapshot version verification | ||
run: | | ||
if ! [[ "${{ steps.version-step.outputs.version }}" =~ ^[0-9]+.[0-9]+.[0-9]+-SNAPSHOT$ ]]; then | ||
echo "Snapshot interrupted: DDI Lifecycle lib version '${{ steps.version-step.outputs.version }}' is not in correct format X.Y.Z-SNAPSHOT" | ||
exit 1 | ||
fi | ||
|
||
- name: Check tag existence | ||
uses: mukunku/[email protected] | ||
id: check-tag-exists | ||
with: | ||
tag: ${{ steps.version-step.outputs.version }} | ||
|
||
- name: Tag verification | ||
run: | | ||
if [[ "${{ steps.check-tag-exists.outputs.exists }}" == "true" ]]; then | ||
echo "Snapshot interrupted: tag '${{ steps.version-step.outputs.version }}' already exists." | ||
exit 1 | ||
fi | ||
|
||
publish-snapshot: | ||
needs: check-version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: ${{ env.JAVA_VERSION }} | ||
|
||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v3 | ||
|
||
- name: Publish DDI Lifecycle lib on Maven Central | ||
run: | | ||
./gradlew :model:publish | ||
env: | ||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | ||
|
||
write-comment: | ||
needs: [check-version, publish-snapshot] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '👋 Version ${{ needs.check-version.outputs.snapshot-version }} published on maven central repository' | ||
}) | ||
|
||
create-tag: | ||
needs: [check-version, publish-snapshot] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create tag | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: 'refs/tags/${{ needs.check-version.outputs.snapshot-version }}', | ||
sha: context.sha | ||
}) | ||
|
||
remove-publish-label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-ecosystem/action-remove-labels@v1 | ||
with: | ||
labels: 'publish-snapshot' |
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
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.
Semver pattern allows richer chains for previous release version or release metadata (https://semver.org/lang/fr/#spec-item-9 and item 10 also). Maybe patterns like
^[0-9]+.[0-9]+.[0-9]+-[0-9A-Za-z-]+$
should be betterThere 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 quite like enforcing "snapshot" since it has a meaning for maven (snapshots have a different overwrite mechanism), and adding other tags introduces some complexity that often feels not necessary
Yet it is restrictive in regards to semver... so we could use the more complex regex.
Isn't the "+" symbol missing for metadata?
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 propose this pattern :
(?>^[0-9]+.[0-9]+.[0-9]+-SNAPSHOT$)|(?>^[0-9]+.[0-9]+.[0-9]+-SNAPSHOT\+[0-9A-Za-z-]+$)
it means that the version must match
^[0-9]+.[0-9]+.[0-9]+-SNAPSHOT$
(for example 1.1.1-SNAPSHOT) or must match^[0-9]+.[0-9]+.[0-9]+-SNAPSHOT\+[0-9A-Za-z-]+$
(for example 1.1.1-SNAPSHOT+feat1). So it is mandatory the version starts with x.y.z-SNAPSHOT and then it may be suffixed by a string wich starts with +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.
great!