Repository navigation
Release #12
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
| name: Release | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: 21 | |
| cache: gradle | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Get version from build.gradle | |
| id: get_version | |
| run: | | |
| VERSION=$(./gradlew properties -q | grep "^version:" | awk '{print $2}') | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected version: $VERSION" | |
| - name: Display current version | |
| run: | | |
| echo "Current version in build.gradle:" | |
| grep "otto_config_version" build.gradle | |
| - name: Build and test | |
| run: ./gradlew clean check | |
| - name: Create git tag | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.VERSION }} | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v$VERSION" -m "Release $VERSION" | |
| git push origin "v$VERSION" | |
| - name: Publish to GitHub Packages | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| run: ./gradlew publishMavenJavaPublicationToGitHubPackagesRepository | |
| - name: Publish to Maven Central | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} | |
| GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} | |
| MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }} | |
| MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }} | |
| run: ./gradlew publishMavenJavaPublicationToMavenCentralRepository | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: Release ${{ steps.get_version.outputs.VERSION }} | |
| tag_name: v${{ steps.get_version.outputs.VERSION }} | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: ${{ contains(steps.get_version.outputs.VERSION, 'SNAPSHOT') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload build artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: | | |
| build/libs/*.jar |