-
-
Notifications
You must be signed in to change notification settings - Fork 24
Introduce release process through GHA #497
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
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ed1e6ca
Introduce release process through GHA
kaikreuzer eb0b4c0
Update .github/workflows/release.yml
kaikreuzer d9a46d4
Update .github/workflows/release.yml
kaikreuzer d3326b0
Replace deprecated actions/create-release@v1 with softprops/action-gh…
Copilot e7f0b22
Fix duplicated POM file lists in release workflow (#527)
Copilot 8a41ea7
Update .github/workflows/release.yml
kaikreuzer fc4a58e
Update .github/workflows/release.yml
kaikreuzer 9bee300
Update .github/workflows/release.yml
kaikreuzer ddd0e47
Update .github/workflows/release.yml
kaikreuzer 32b9fa0
Update .github/workflows/release.yml
kaikreuzer 0d5c7cb
Add explicit fail-fast behavior for Maven Central deployment in relea…
Copilot 5378bc7
Update .github/workflows/release.yml
kaikreuzer a921510
Update .github/workflows/release.yml
kaikreuzer b892ae1
Update .github/workflows/release.yml
kaikreuzer 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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,259 @@ | ||
| # This workflow handles the complete release process for static-code-analysis | ||
| # It converts snapshot to release version, deploys to Maven Central via OSSRH, | ||
| # and then bumps to the next snapshot version | ||
|
|
||
| name: Release to Maven Central | ||
| permissions: | ||
| contents: write | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| release_version: | ||
| description: 'Release version (e.g., 0.18.0)' | ||
| required: true | ||
| type: string | ||
| next_snapshot_version: | ||
| description: 'Next snapshot version (e.g., 0.19.0-SNAPSHOT)' | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Release to Maven Central | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up JDK 11 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: 11 | ||
| distribution: 'temurin' | ||
| cache: maven | ||
| server-id: ossrh | ||
| server-username: OSSRH_USERNAME | ||
| server-password: OSSRH_PASSWORD | ||
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
| gpg-passphrase: GPG_PASSPHRASE | ||
|
|
||
| - name: Configure Git | ||
| run: | | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Update version to release version | ||
| run: | | ||
| mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }} | ||
| mvn versions:commit | ||
|
|
||
| - name: Update parent POM versions in modules | ||
| run: | | ||
| # Update parent version in all child POMs | ||
| for pom in $(find . -name pom.xml -not -path "*/target/*" -not -path "*/src/test/resources/*"); do | ||
| if [ -f "$pom" ]; then | ||
| mvn versions:update-parent -DparentVersion=${{ github.event.inputs.release_version }} -f "$pom" | ||
| mvn versions:commit -f "$pom" | ||
| fi | ||
| done | ||
|
|
||
| - name: Verify release version | ||
| run: | | ||
| echo "Updated version to:" | ||
| mvn help:evaluate -Dexpression=project.version -q -DforceStdout | ||
|
|
||
| - name: Build without tests | ||
| run: mvn clean compile -DskipTests=true -DskipChecks=true | ||
|
|
||
| - name: Deploy to Maven Central | ||
| id: maven-deploy | ||
| env: | ||
| OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
| OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| run: | | ||
| # Fail fast: If this step fails, no git operations will occur | ||
| mvn -DskipTests=true -DskipChecks=true -DperformRelease=true clean deploy | ||
|
|
||
| - name: Trigger Central Publisher Portal Upload | ||
| env: | ||
| OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
| OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
| CENTRAL_NAMESPACE: ${{ secrets.CENTRAL_NAMESPACE }} | ||
| run: | | ||
| echo "Triggering manual upload to Central Publisher Portal..." | ||
|
|
||
| # Create base64 encoded credentials for Basic Auth | ||
| CREDENTIALS=$(echo -n "$OSSRH_USERNAME:$OSSRH_PASSWORD" | base64) | ||
|
|
||
| # Make POST request to trigger upload | ||
| HTTP_STATUS=$(curl -s -o response.json -w "%{http_code}" \ | ||
| -X POST \ | ||
| -H "Authorization: Basic $CREDENTIALS" \ | ||
kaikreuzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -H "Content-Type: application/json" \ | ||
| "https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$CENTRAL_NAMESPACE") | ||
|
|
||
| echo "HTTP Status: $HTTP_STATUS" | ||
| echo "Response:" | ||
| cat response.json | ||
kaikreuzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if [ $HTTP_STATUS -eq 200 ] || [ $HTTP_STATUS -eq 201 ]; then | ||
| echo "✅ Successfully triggered upload to Central Publisher Portal" | ||
| else | ||
| echo "❌ Failed to trigger upload (HTTP $HTTP_STATUS)" | ||
| echo "Response details:" | ||
| cat response.json | ||
| exit 1 | ||
| fi | ||
kaikreuzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Collect all POM files for commit | ||
| # This step only runs if Maven Central deployment succeeded (fail-fast behavior) | ||
| if: success() | ||
| run: | | ||
| # Add all modified tracked POM files | ||
| git add -u **/pom.xml | ||
|
|
||
| - name: Commit release version and push to main branch | ||
| # This step only runs if Maven Central deployment succeeded (fail-fast behavior) | ||
| if: success() | ||
| run: | | ||
| git commit -m "Release version ${{ github.event.inputs.release_version }}" | ||
| git push origin | ||
|
|
||
| - name: Create and push release tag | ||
| # This step only runs if Maven Central deployment and commit succeeded (fail-fast behavior) | ||
| if: success() | ||
| run: | | ||
| git tag -a "v${{ github.event.inputs.release_version }}" -m "Release version ${{ github.event.inputs.release_version }}" | ||
| git push origin "v${{ github.event.inputs.release_version }}" | ||
|
|
||
| - name: Update to next snapshot version | ||
| # This step only runs after successful tag creation (fail-fast behavior) | ||
| if: success() | ||
| run: | | ||
| mvn versions:set -DnewVersion=${{ github.event.inputs.next_snapshot_version }} | ||
| mvn versions:commit | ||
|
|
||
| - name: Update parent POM versions in modules to snapshot | ||
| # This step only runs after successful tag creation (fail-fast behavior) | ||
| if: success() | ||
| run: | | ||
| # Update parent version in all child POMs | ||
| # Find all pom.xml files except the root pom.xml | ||
| for pom in $(find . -name pom.xml ! -path "./pom.xml"); do | ||
| if [ -f "$pom" ]; then | ||
| mvn versions:update-parent -DparentVersion=${{ github.event.inputs.next_snapshot_version }} -f "$pom" | ||
| mvn versions:commit -f "$pom" | ||
| fi | ||
| done | ||
|
|
||
| - name: Verify snapshot version | ||
| if: success() | ||
| run: | | ||
| echo "Updated version to:" | ||
| mvn help:evaluate -Dexpression=project.version -q -DforceStdout | ||
|
|
||
| - name: Commit and push snapshot version | ||
| # This step only runs after successful deployment and tag creation (fail-fast behavior) | ||
| if: success() | ||
| run: | | ||
| # Add all modified POM files | ||
| git add **/pom.xml | ||
kaikreuzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| git commit -m "Prepare for next development iteration: ${{ github.event.inputs.next_snapshot_version }}" | ||
| git push origin | ||
|
|
||
| - name: Create GitHub Release | ||
| # This step only runs after all previous steps succeeded (fail-fast behavior) | ||
| if: success() | ||
| uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 | ||
| with: | ||
| tag_name: "v${{ github.event.inputs.release_version }}" | ||
| name: "Release ${{ github.event.inputs.release_version }}" | ||
| body: | | ||
| Release ${{ github.event.inputs.release_version }} | ||
|
|
||
| This release has been automatically deployed to Maven Central. | ||
|
|
||
| **Artifacts:** | ||
| - `org.openhab.tools.sat:sat-plugin:${{ github.event.inputs.release_version }}` | ||
| - `org.openhab.tools.sat:sat-extension:${{ github.event.inputs.release_version }}` | ||
| - `org.openhab.tools:openhab-codestyle:${{ github.event.inputs.release_version }}` | ||
| - `org.openhab.tools.sat.custom-checks:checkstyle-rules:${{ github.event.inputs.release_version }}` | ||
| - `org.openhab.tools.sat.custom-checks:pmd-rules:${{ github.event.inputs.release_version }}` | ||
| - `org.openhab.tools.sat.custom-checks:findbugs-rules:${{ github.event.inputs.release_version }}` | ||
|
|
||
| **Maven Central - SAT Plugin:** | ||
| ```xml | ||
| <plugin> | ||
| <groupId>org.openhab.tools.sat</groupId> | ||
| <artifactId>sat-plugin</artifactId> | ||
| <version>${{ github.event.inputs.release_version }}</version> | ||
| </plugin> | ||
| ``` | ||
|
|
||
| **Maven Central - SAT Extension:** | ||
| ```xml | ||
| <extension> | ||
| <groupId>org.openhab.tools.sat</groupId> | ||
| <artifactId>sat-extension</artifactId> | ||
| <version>${{ github.event.inputs.release_version }}</version> | ||
| </extension> | ||
| ``` | ||
|
|
||
| **Maven Central - Codestyle:** | ||
| ```xml | ||
| <dependency> | ||
| <groupId>org.openhab.tools</groupId> | ||
| <artifactId>openhab-codestyle</artifactId> | ||
| <version>${{ github.event.inputs.release_version }}</version> | ||
| </dependency> | ||
| ``` | ||
| draft: false | ||
| prerelease: false | ||
|
|
||
| check-central-deployment: | ||
| name: Verify Maven Central Deployment | ||
| needs: release | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Wait for Maven Central synchronization | ||
| run: | | ||
| echo "Waiting for artifacts to be synchronized to Maven Central..." | ||
| sleep 300 # Wait 5 minutes for initial propagation | ||
|
|
||
| - name: Check Maven Central availability | ||
| run: | | ||
| RELEASE_VERSION="${{ github.event.inputs.release_version }}" | ||
| MAX_ATTEMPTS=12 | ||
| ATTEMPT=1 | ||
|
|
||
| while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do | ||
| echo "Attempt $ATTEMPT of $MAX_ATTEMPTS: Checking Maven Central for version $RELEASE_VERSION..." | ||
|
|
||
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ | ||
| "https://repo1.maven.org/maven2/org/openhab/tools/sat/sat-plugin/$RELEASE_VERSION/sat-plugin-$RELEASE_VERSION.pom") | ||
|
|
||
| if [ $HTTP_STATUS -eq 200 ]; then | ||
| echo "✅ Artifact successfully found on Maven Central!" | ||
| echo "🔗 Maven Central URL: https://repo1.maven.org/maven2/org/openhab/tools/sat/sat-plugin/$RELEASE_VERSION/" | ||
| echo "📦 Maven Central search: https://search.maven.org/artifact/org.openhab.tools.sat/sat-plugin/$RELEASE_VERSION/maven-plugin" | ||
| break | ||
| else | ||
| echo "❌ Artifact not yet available (HTTP $HTTP_STATUS). Waiting..." | ||
| if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then | ||
| echo "⚠️ Maximum attempts reached. Deployment may still be in progress." | ||
| echo "🕐 It can take up to 2 hours for artifacts to appear on Maven Central." | ||
| echo "📋 Check manually at: https://search.maven.org/artifact/org.openhab.tools.sat/sat-plugin/$RELEASE_VERSION/maven-plugin" | ||
| else | ||
| sleep 300 # Wait 5 minutes between attempts | ||
| fi | ||
| fi | ||
|
|
||
| ATTEMPT=$((ATTEMPT + 1)) | ||
| done | ||
kaikreuzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.