|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + versionTag: |
| 7 | + description: 'Version Tag (semantic version)' |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + - name: Set up JDK 8 |
| 17 | + uses: actions/setup-java@v4 |
| 18 | + with: |
| 19 | + distribution: 'zulu' |
| 20 | + java-version: '8' |
| 21 | + settings-path: ${{ github.workspace }} |
| 22 | + |
| 23 | + - name: Load local Maven repository cache |
| 24 | + uses: actions/cache@v3 |
| 25 | + with: |
| 26 | + path: ~/.m2/repository |
| 27 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 28 | + restore-keys: | |
| 29 | + ${{ runner.os }}-maven- |
| 30 | +
|
| 31 | + - name: Set up git |
| 32 | + run: | |
| 33 | + git config --global user.email "[email protected]" |
| 34 | + git config --global user.name "JohnnyQ5" |
| 35 | +
|
| 36 | + - name: Set version in Maven project |
| 37 | + run: mvn versions:set -DnewVersion=${{ github.event.inputs.versionTag }} |
| 38 | + |
| 39 | + - name: Build with Maven |
| 40 | + run: mvn -B package --file pom.xml |
| 41 | + |
| 42 | + - name: Create Release Notes |
| 43 | + if: ${{ !startsWith(github.ref, 'refs/tags/') |
| 44 | + && !( contains(github.event.inputs.versionTag, 'alpha') |
| 45 | + || contains(github.event.inputs.versionTag, 'beta') |
| 46 | + || contains(github.event.inputs.versionTag, 'rc')) }} |
| 47 | + uses: actions/github-script@v7 |
| 48 | + with: |
| 49 | + github-token: ${{secrets.JOHNNY_Q5_REPORTS_TOKEN}} |
| 50 | + script: | |
| 51 | + await github.request(`POST /repos/${{ github.repository }}/releases`, { |
| 52 | + tag_name: "${{ github.event.inputs.versionTag }}", |
| 53 | + generate_release_notes: true |
| 54 | + }); |
| 55 | +
|
| 56 | + - name: Create Pre-Release Notes |
| 57 | + if: ${{ !startsWith(github.ref, 'refs/tags/') |
| 58 | + && ( contains(github.event.inputs.versionTag, 'alpha') |
| 59 | + || contains(github.event.inputs.versionTag, 'beta') |
| 60 | + || contains(github.event.inputs.versionTag, 'rc')) }} |
| 61 | + uses: actions/github-script@v7 |
| 62 | + with: |
| 63 | + github-token: ${{secrets.JOHNNY_Q5_REPORTS_TOKEN}} |
| 64 | + script: | |
| 65 | + await github.request(`POST /repos/${{ github.repository }}/releases`, { |
| 66 | + tag_name: "${{ github.event.inputs.versionTag }}", |
| 67 | + generate_release_notes: true, |
| 68 | + prerelease: true |
| 69 | + }); |
| 70 | +
|
| 71 | + - name: Publish artefact to QBiC Nexus Repository |
| 72 | + run: VAADIN_OFFLINE_KEY=${{ secrets.VAADIN_SERVER_23_2 }} mvn --quiet --settings $GITHUB_WORKSPACE/.github.settings.xml -Pproduction -Dvaadin.force.production.build=true deploy |
| 73 | + env: |
| 74 | + MAVEN_REPO_USERNAME: ${{ secrets.NEXUS_USERNAME }} |
| 75 | + MAVEN_REPO_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} |
| 76 | + |
| 77 | + - name: Switch to new branch |
| 78 | + run: git checkout -b release/set-version-to-${{ github.event.inputs.versionTag }} |
| 79 | + |
| 80 | + - name: Set remote branch |
| 81 | + run: git push --set-upstream origin release/set-version-to-${{ github.event.inputs.versionTag }} |
| 82 | + |
| 83 | + - name: Checkin commit |
| 84 | + run: git commit . -m 'Set version to ${{ github.event.inputs.versionTag }}' |
| 85 | + |
| 86 | + - name: Push to Github |
| 87 | + run: git push |
| 88 | + |
| 89 | + - name: Open PR with version bump |
| 90 | + uses: actions/github-script@v7 |
| 91 | + with: |
| 92 | + github-token: ${{secrets.JOHNNY_Q5_REPORTS_TOKEN}} |
| 93 | + script: | |
| 94 | + await github.request(`POST /repos/${{ github.repository }}/pulls`, { |
| 95 | + title: 'Update version to ${{ github.event.inputs.versionTag }}', |
| 96 | + head: 'release/set-version-to-${{ github.event.inputs.versionTag }}', |
| 97 | + base: 'main' |
| 98 | + }); |
0 commit comments