|
9 | 9 | name: Release |
10 | 10 |
|
11 | 11 | on: |
12 | | - push: |
13 | | - tags: |
14 | | - - v* |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + version: |
| 15 | + description: 'Release version' |
| 16 | + required: true |
| 17 | + next: |
| 18 | + description: 'Next version' |
| 19 | + required: false |
| 20 | + |
| 21 | +env: |
| 22 | + JAVA_VERSION: '11' |
| 23 | + JAVA_DISTRO: 'temurin' |
15 | 24 |
|
16 | 25 | jobs: |
17 | 26 | release: |
18 | | - name: Release |
19 | 27 | runs-on: ubuntu-latest |
20 | | - |
21 | 28 | steps: |
22 | | - - name: Version |
23 | | - id: version |
24 | | - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} |
25 | | - |
26 | | - - name: Checkout |
27 | | - uses: actions/checkout@v4 |
| 29 | + - uses: actions/checkout@v4 |
28 | 30 | with: |
29 | 31 | fetch-depth: 0 |
30 | 32 |
|
31 | | - - name: Cache Maven |
32 | | - uses: actions/cache@v4 |
33 | | - with: |
34 | | - path: ~/.m2/repository |
35 | | - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
36 | | - restore-keys: ${{ runner.os }}-m2 |
37 | | - |
38 | 33 | - name: Setup Java |
39 | 34 | uses: actions/setup-java@v4 |
40 | 35 | with: |
41 | | - java-version: 11 |
42 | | - distribution: 'temurin' |
43 | | - server-id: central |
44 | | - server-username: MAVEN_USERNAME |
45 | | - server-password: MAVEN_CENTRAL_TOKEN |
46 | | - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} |
47 | | - gpg-passphrase: MAVEN_GPG_PASSPHRASE |
| 36 | + java-version: ${{ env.JAVA_VERSION }} |
| 37 | + distribution: ${{ env.JAVA_DISTRO }} |
| 38 | + cache: maven |
48 | 39 |
|
49 | | - - name: Release |
50 | | - env: |
51 | | - MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
52 | | - MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} |
53 | | - MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 40 | + - name: Set release version |
| 41 | + id: version |
| 42 | + run: | |
| 43 | + BRANCH="oss-quickstart-${{ github.event.inputs.version }}" |
| 44 | + RELEASE_VERSION=${{ github.event.inputs.version }} |
| 45 | + NEXT_VERSION=${{ github.event.inputs.next }} |
| 46 | + PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'` |
| 47 | + COMPUTED_NEXT_VERSION="${PLAIN_VERSION}-SNAPSHOT" |
| 48 | + if [ -z $NEXT_VERSION ] |
| 49 | + then |
| 50 | + NEXT_VERSION=$COMPUTED_NEXT_VERSION |
| 51 | + fi |
| 52 | + git checkout -b $BRANCH |
| 53 | + ./mvnw -ntp -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION |
| 54 | + git config --global user.email "[email protected]" |
| 55 | + git config --global user.name "moditect-release-bot" |
| 56 | + git commit -a -m "Releasing version $RELEASE_VERSION" |
| 57 | + git push origin $BRANCH |
| 58 | + echo "BRANCH=$BRANCH" >> $GITHUB_ENV |
| 59 | + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV |
| 60 | + echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV |
| 61 | + echo "PLAIN_VERSION=$PLAIN_VERSION" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - name: Stage |
54 | 64 | run: | |
55 | 65 | export GPG_TTY=$(tty) |
56 | | - export MAVEN_OPTS=--illegal-access=permit |
57 | | - mvn --no-transfer-progress -B --file pom.xml \ |
| 66 | + ./mvnw -ntp -B --file pom.xml \ |
58 | 67 | -Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git \ |
59 | | - -Dmaven.site.skip=true -Drelease=true deploy |
| 68 | + -Dmaven.site.skip=true -Drelease=true -Ppublication,stage |
60 | 69 |
|
61 | | - - name: Release to GitHub |
| 70 | + - name: Release |
62 | 71 | env: |
63 | 72 | JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + JRELEASER_BRANCH: ${{ env.BRANCH }} |
| 74 | + JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 75 | + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} |
| 76 | + JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 77 | + JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 78 | + JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 79 | + run: | |
| 80 | + ./mvnw -ntp -B --file pom.xml -Pjreleaser jreleaser:release |
| 81 | +
|
| 82 | + - name: JReleaser output |
| 83 | + if: always() |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: jreleaser-release |
| 87 | + path: | |
| 88 | + parent/target/jreleaser/trace.log |
| 89 | + parent/target/jreleaser/output.properties |
| 90 | +
|
| 91 | + - name: Set next version |
64 | 92 | run: | |
65 | | - mvn -B --file pom.xml -pl :ossquickstart-aggregator -Pjreleaser jreleaser:release |
| 93 | + ./mvnw -ntp -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }} |
| 94 | + git config --global user.email "[email protected]" |
| 95 | + git config --global user.name "moditect-release-bot" |
| 96 | + git commit -a -m "Next version ${{ env.NEXT_VERSION }}" |
| 97 | + git push origin ${{ env.BRANCH }} |
0 commit comments