|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: "Release version, e.g. 2.0.16-emnify.1 (tag v<version> is created)" |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write # create the release and upload the .hpi asset |
| 16 | + |
| 17 | +jobs: |
| 18 | + release: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 # full history for the git-changelist maven extension |
| 25 | + |
| 26 | + - name: Resolve version and tag |
| 27 | + id: v |
| 28 | + run: | |
| 29 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 30 | + VERSION="${{ inputs.version }}" |
| 31 | + TAG="v${VERSION}" |
| 32 | + else |
| 33 | + TAG="${GITHUB_REF_NAME}" |
| 34 | + VERSION="${TAG#v}" |
| 35 | + fi |
| 36 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 37 | + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" |
| 38 | + echo "Resolved version=${VERSION} tag=${TAG}" |
| 39 | +
|
| 40 | + - name: Set up JDK 17 |
| 41 | + uses: actions/setup-java@v4 |
| 42 | + with: |
| 43 | + distribution: temurin |
| 44 | + java-version: "17" |
| 45 | + cache: maven |
| 46 | + |
| 47 | + # Tests run in the standard plugin CI; the release job only packages. |
| 48 | + # Flip -DskipTests off here if you want the release gated on tests. |
| 49 | + - name: Build HPI |
| 50 | + run: > |
| 51 | + mvn -B -ntp -DskipTests |
| 52 | + -Drevision=${{ steps.v.outputs.version }} -Dchangelist= |
| 53 | + clean package |
| 54 | +
|
| 55 | + - name: Stage versioned asset |
| 56 | + id: asset |
| 57 | + run: | |
| 58 | + set -euo pipefail |
| 59 | + SRC=$(ls target/*.hpi) |
| 60 | + DEST="target/atlassian-jira-software-cloud-${{ steps.v.outputs.version }}.hpi" |
| 61 | + cp "$SRC" "$DEST" |
| 62 | + echo "path=${DEST}" >> "$GITHUB_OUTPUT" |
| 63 | + ls -la "$DEST" |
| 64 | +
|
| 65 | + - name: Create GitHub Release with HPI |
| 66 | + env: |
| 67 | + GH_TOKEN: ${{ github.token }} |
| 68 | + run: | |
| 69 | + set -euo pipefail |
| 70 | + TAG="${{ steps.v.outputs.tag }}" |
| 71 | + # Create the tag on this commit if it does not already exist (manual runs). |
| 72 | + gh release create "$TAG" \ |
| 73 | + --target "$GITHUB_SHA" \ |
| 74 | + --title "$TAG" \ |
| 75 | + --generate-notes \ |
| 76 | + "${{ steps.asset.outputs.path }}" |
0 commit comments