|
| 1 | +name: Gradle Publish [snapshot] |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + check-branch: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - name: Check Branch |
| 11 | + if: github.ref != 'refs/heads/main' |
| 12 | + run: | |
| 13 | + echo "::error title=wrong branch selected::this workflow must be run on the 'main' branch" |
| 14 | + exit 1 |
| 15 | +
|
| 16 | + publish-snapshot: |
| 17 | + needs: check-branch |
| 18 | + |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v5 |
| 23 | + with: |
| 24 | + ref: main |
| 25 | + |
| 26 | + - name: Set up JDK 17 |
| 27 | + uses: actions/setup-java@v5 |
| 28 | + with: |
| 29 | + java-version: "17" |
| 30 | + distribution: "temurin" |
| 31 | + |
| 32 | + - name: Setup Gradle |
| 33 | + uses: gradle/actions/setup-gradle@v4 |
| 34 | + |
| 35 | + - name: Evaluate Version |
| 36 | + id: version |
| 37 | + env: |
| 38 | + VERSION_FILE: .github/utils/next_version.txt |
| 39 | + run: | |
| 40 | + if [ -n "${VERSION_FILE:-}" ] && [ -f "$VERSION_FILE" ]; then |
| 41 | + bash .github/utils/validate_version_file.sh "$VERSION_FILE" |
| 42 | + NEXT_VERSION=$(cat "$VERSION_FILE" | tr -d '[:space:]') # trim whitespaces |
| 43 | + echo "::notice::using version from $VERSION_FILE: $NEXT_VERSION" |
| 44 | + else |
| 45 | + echo "::error::file $VERSION_FILE not found" |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | +
|
| 49 | + NEXT_VERSION="${NEXT_VERSION#v}" # strip leading 'v' if present |
| 50 | + SNAPSHOT_VERSION="${NEXT_VERSION}-SNAPSHOT" |
| 51 | +
|
| 52 | + echo "::notice::evaluated snapshot version: $SNAPSHOT_VERSION" |
| 53 | + echo "version=$SNAPSHOT_VERSION" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + - name: Publish Snapshot with Gradle Wrapper |
| 56 | + env: |
| 57 | + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} |
| 58 | + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} |
| 59 | + PUBLISHING_USERNAME: ${{ secrets.PUBLISHING_USERNAME }} |
| 60 | + PUBLISHING_PASSWORD: ${{ secrets.PUBLISHING_PASSWORD }} |
| 61 | + run: | |
| 62 | + ./gradlew -Pversion="${{ steps.version.outputs.version }}" publishAllPublicationsToCentralPortalSnapshots |
0 commit comments