|
17 | 17 | name: Release |
18 | 18 |
|
19 | 19 | on: |
20 | | - workflow_dispatch: { } |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + release-version: |
| 23 | + required: false |
| 24 | + default: '' |
| 25 | + description: >- |
| 26 | + Release version (e.g. 5.7.0 or 5.7.0-rc.1). |
| 27 | + Leave empty to let Maven compute it from the current SNAPSHOT version. |
| 28 | + type: string |
| 29 | + development-version: |
| 30 | + required: false |
| 31 | + default: '' |
| 32 | + description: >- |
| 33 | + Next development version (e.g. 5.8.0-SNAPSHOT). |
| 34 | + Leave empty for automatic increment (e.g. 5.7.1-SNAPSHOT or 5.7.0-rc.2-SNAPSHOT). |
| 35 | + type: string |
| 36 | + dry-run: |
| 37 | + required: false |
| 38 | + default: false |
| 39 | + description: >- |
| 40 | + Perform a dry run without pushing changes or creating releases. |
| 41 | + type: boolean |
21 | 42 |
|
22 | 43 | permissions: { } |
23 | 44 |
|
24 | 45 | jobs: |
25 | | - create-release: |
26 | | - name: Create Release |
| 46 | + release: |
| 47 | + name: Release |
27 | 48 | runs-on: ubuntu-latest |
28 | 49 | timeout-minutes: 15 |
29 | 50 | permissions: |
30 | 51 | contents: write # Required to create releases |
31 | 52 | packages: write # Required to push images to ghcr.io |
32 | 53 | if: "${{ github.repository_owner == 'DependencyTrack' }}" |
33 | 54 | steps: |
34 | | - - name: Checkout Repository |
35 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2 |
36 | | - with: |
37 | | - persist-credentials: false |
38 | | - - name: Set up JDK |
39 | | - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # tag=v5.2.0 |
40 | | - with: |
41 | | - java-version: '21' |
42 | | - distribution: 'temurin' |
43 | | - cache: maven |
44 | | - - name: Set up QEMU |
45 | | - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # tag=v3.7.0 |
46 | | - - name: Set up Docker Buildx |
47 | | - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # tag=v3.12.0 |
48 | | - with: |
49 | | - install: true |
50 | | - - name: Docker login |
51 | | - uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # tag=v3.6.0 |
52 | | - with: |
53 | | - registry: ghcr.io |
54 | | - username: ${{ github.repository_owner }} |
55 | | - password: ${{ github.repository_owner == 'DependencyTrack' && secrets.BOT_IMAGE_PUSH_TOKEN || secrets.GITHUB_TOKEN }} |
56 | | - - name: Perform Release |
57 | | - run: |- |
58 | | - git config user.name "dependencytrack-bot" |
59 | | - git config user.email "106437498+dependencytrack-bot@users.noreply.github.com" |
60 | | - |
61 | | - BUILD_ARGS=( |
62 | | - '-Dcheckstyle.skip' |
63 | | - '-DskipTests' |
64 | | - '-Dquarkus.container-image.registry=ghcr.io' |
65 | | - "-Dquarkus.container-image.group=${GITHUB_REPOSITORY_OWNER,,}" |
66 | | - '-Dquarkus.container-image.additional-tags=latest' |
67 | | - '-Dquarkus.container-image.build=true' |
68 | | - '-Dquarkus.container-image.push=true' |
69 | | - '-Dquarkus.docker.buildx.platform=linux/amd64,linux/arm64' |
70 | | - ) |
71 | | - |
72 | | - mvn -B --no-transfer-progress release:prepare \ |
73 | | - -DpreparationGoals="clean verify" \ |
74 | | - -Darguments="${BUILD_ARGS[*]}" \ |
75 | | - -DpushChanges=false |
76 | | - - name: Push Changes |
77 | | - uses: ad-m/github-push-action@master |
78 | | - with: |
79 | | - branch: ${{ github.ref }} |
80 | | - github_token: ${{ secrets.BOT_RELEASE_TOKEN }} |
81 | | - tags: true |
82 | | - - name: Determine Release Tag |
83 | | - id: determine-release-tag |
84 | | - run: |- |
85 | | - TAG_NAME="$(sed -nr 's/^scm.tag=(v[0-9.]+)$/\1/p' release.properties)" |
86 | | - echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT |
87 | | - - name: Create GitHub Release |
88 | | - env: |
89 | | - GITHUB_TOKEN: "${{ secrets.BOT_RELEASE_TOKEN }}" |
90 | | - run: |- |
91 | | - gh release create "${{ steps.determine-release-tag.outputs.TAG_NAME }}" \ |
92 | | - --target ${{ github.ref_name }} \ |
93 | | - --verify-tag \ |
94 | | - --generate-notes |
95 | | - - name: Upload BOMs to GitHub Release |
96 | | - env: |
97 | | - GITHUB_TOKEN: "${{ secrets.BOT_RELEASE_TOKEN }}" |
98 | | - run: |- |
99 | | - find . -name quarkus-run-cyclonedx.json -exec \ |
100 | | - sh -c 'mv {} "$(echo {} | cut -d "/" -f 2)-${{ steps.determine-release-tag.outputs.TAG_NAME }}.cdx.json"' \; |
101 | | - gh release upload "${{ steps.determine-release-tag.outputs.TAG_NAME }}" \ |
102 | | - ./*.cdx.json --clobber |
| 55 | + - name: Checkout Repository |
| 56 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2 |
| 57 | + with: |
| 58 | + token: ${{ github.repository_owner == 'DependencyTrack' && secrets.BOT_RELEASE_TOKEN || secrets.GITHUB_TOKEN }} |
| 59 | + fetch-depth: 0 |
| 60 | + |
| 61 | + - name: Set up JDK |
| 62 | + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # tag=v5.2.0 |
| 63 | + with: |
| 64 | + distribution: 'temurin' |
| 65 | + java-version: '21' |
| 66 | + cache: 'maven' |
| 67 | + |
| 68 | + - name: Set up QEMU |
| 69 | + uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # tag=v3.7.0 |
| 70 | + |
| 71 | + - name: Set up Docker Buildx |
| 72 | + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # tag=v3.12.0 |
| 73 | + with: |
| 74 | + install: true |
| 75 | + |
| 76 | + - name: Docker login |
| 77 | + if: ${{ !inputs.dry-run }} |
| 78 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # tag=v3.6.0 |
| 79 | + with: |
| 80 | + registry: ghcr.io |
| 81 | + username: ${{ github.repository_owner }} |
| 82 | + password: ${{ github.repository_owner == 'DependencyTrack' && secrets.BOT_IMAGE_PUSH_TOKEN || secrets.GITHUB_TOKEN }} |
| 83 | + |
| 84 | + - name: Configure Git |
| 85 | + run: | |
| 86 | + git config user.name "dependencytrack-bot" |
| 87 | + git config user.email "106437498+dependencytrack-bot@users.noreply.github.com" |
| 88 | +
|
| 89 | + - name: Perform Maven Release |
| 90 | + run: |- |
| 91 | + MAVEN_ARGS="-B" |
| 92 | + if [[ -n "${{ inputs.release-version }}" ]]; then |
| 93 | + MAVEN_ARGS="${MAVEN_ARGS} -DreleaseVersion=${{ inputs.release-version }}" |
| 94 | + fi |
| 95 | + if [[ -n "${{ inputs.development-version }}" ]]; then |
| 96 | + MAVEN_ARGS="${MAVEN_ARGS} -DdevelopmentVersion=${{ inputs.development-version }}" |
| 97 | + fi |
| 98 | + if [[ "${{ inputs.dry-run }}" == "true" ]]; then |
| 99 | + MAVEN_ARGS="${MAVEN_ARGS} -DdryRun=true" |
| 100 | + fi |
| 101 | + export MAVEN_ARGS |
| 102 | +
|
| 103 | + IS_PRERELEASE="false" |
| 104 | + if [[ -n "${{ inputs.release-version }}" ]]; then |
| 105 | + if [[ "${{ inputs.release-version }}" == *-* ]]; then |
| 106 | + IS_PRERELEASE="true" |
| 107 | + fi |
| 108 | + else |
| 109 | + CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 110 | + RELEASE_VERSION="${CURRENT_VERSION%-SNAPSHOT}" |
| 111 | + if [[ "${RELEASE_VERSION}" == *-* ]]; then |
| 112 | + IS_PRERELEASE="true" |
| 113 | + fi |
| 114 | + fi |
| 115 | +
|
| 116 | + BUILD_ARGS=( |
| 117 | + "-Dquarkus.container-image.group=${GITHUB_REPOSITORY_OWNER,,}" |
| 118 | + '-Dquarkus.container-image.build=true' |
| 119 | + '-Dquarkus.docker.buildx.platform=linux/amd64,linux/arm64' |
| 120 | + ) |
| 121 | +
|
| 122 | + if [[ "${IS_PRERELEASE}" != "true" ]]; then |
| 123 | + BUILD_ARGS+=('-Dquarkus.container-image.additional-tags=latest') |
| 124 | + fi |
| 125 | +
|
| 126 | + if [[ "${{ inputs.dry-run }}" == "true" ]]; then |
| 127 | + BUILD_ARGS+=('-Dquarkus.container-image.push=false') |
| 128 | + else |
| 129 | + BUILD_ARGS+=('-Dquarkus.container-image.push=true') |
| 130 | + fi |
| 131 | +
|
| 132 | + mvn release:prepare -Darguments="${BUILD_ARGS[*]}" |
| 133 | +
|
| 134 | + - name: Create GitHub Release |
| 135 | + if: ${{ !inputs.dry-run }} |
| 136 | + env: |
| 137 | + GITHUB_TOKEN: "${{ secrets.BOT_RELEASE_TOKEN }}" |
| 138 | + run: | |
| 139 | + RELEASE_VERSION=$(git describe --tags --abbrev=0) |
| 140 | + echo "Release version: ${RELEASE_VERSION}" |
| 141 | +
|
| 142 | + PRERELEASE_FLAG="" |
| 143 | + if [[ "${RELEASE_VERSION}" == *-* ]]; then |
| 144 | + PRERELEASE_FLAG="--prerelease" |
| 145 | + fi |
| 146 | +
|
| 147 | + gh release create "${RELEASE_VERSION}" \ |
| 148 | + --generate-notes \ |
| 149 | + ${PRERELEASE_FLAG} |
| 150 | +
|
| 151 | + - name: Upload BOMs to GitHub Release |
| 152 | + if: ${{ !inputs.dry-run }} |
| 153 | + env: |
| 154 | + GITHUB_TOKEN: "${{ secrets.BOT_RELEASE_TOKEN }}" |
| 155 | + run: |- |
| 156 | + RELEASE_VERSION=$(git describe --tags --abbrev=0) |
| 157 | + for bom in $(find . -name quarkus-run-cyclonedx.json); do |
| 158 | + MODULE=$(echo "${bom}" | cut -d "/" -f 2) |
| 159 | + mv "${bom}" "${MODULE}-${RELEASE_VERSION}.cdx.json" |
| 160 | + done |
| 161 | + gh release upload "${RELEASE_VERSION}" ./*.cdx.json --clobber |
0 commit comments