|
1 |
| -# SPDX-FileCopyrightText: 2022 Alliander N.V. |
| 1 | +# SPDX-FileCopyrightText: 2023 Alliander N.V. |
2 | 2 | #
|
3 | 3 | # SPDX-License-Identifier: Apache-2.0
|
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
4 | 8 |
|
5 |
| -name: Release Project |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
6 | 12 |
|
7 |
| -on: |
8 |
| - release: |
9 |
| - types: [ released ] |
| 13 | +name: release-please |
10 | 14 |
|
11 | 15 | jobs:
|
12 |
| - push_to_registry: |
13 |
| - name: Build and publish |
| 16 | + release_please: |
14 | 17 | runs-on: ubuntu-latest
|
15 |
| - |
16 | 18 | steps:
|
| 19 | + - uses: google-github-actions/release-please-action@v4 |
| 20 | + id: release |
| 21 | + with: |
| 22 | + release-type: maven |
| 23 | + package-name: compas-scl-auto-alignment |
17 | 24 | - name: Checkout
|
| 25 | + if: ${{ steps.release.outputs.release_created }} |
18 | 26 | uses: actions/checkout@v4
|
19 | 27 |
|
20 | 28 | - name: Cache Docker Register
|
21 |
| - uses: actions/cache@v3 |
| 29 | + if: ${{ steps.release.outputs.release_created }} |
| 30 | + uses: actions/cache@v4 |
22 | 31 | with:
|
23 | 32 | path: /tmp/.buildx-cache
|
24 | 33 | key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }}
|
25 | 34 | - name: Cache Maven packages
|
26 |
| - uses: actions/cache@v3 |
| 35 | + if: ${{ steps.release.outputs.release_created }} |
| 36 | + uses: actions/cache@v4 |
27 | 37 | with:
|
28 | 38 | path: ~/.m2
|
29 | 39 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
30 | 40 | restore-keys: ${{ runner.os }}-m2
|
31 | 41 |
|
32 | 42 | - name: Extract tag name
|
| 43 | + if: ${{ steps.release.outputs.release_created }} |
33 | 44 | id: extract_tagname
|
34 | 45 | shell: bash
|
35 | 46 | # Extract the tag name from the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
|
36 | 47 | run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
|
37 | 48 |
|
38 | 49 | - name: Set up JDK 17
|
39 |
| - |
| 50 | + if: ${{ steps.release.outputs.release_created }} |
| 51 | + uses: actions/setup-java@v4 |
40 | 52 | with:
|
41 | 53 | distribution: 'zulu'
|
42 | 54 | java-version: '17'
|
43 | 55 | - name: Set up Docker Buildx
|
| 56 | + if: ${{ steps.release.outputs.release_created }} |
44 | 57 | id: buildx
|
45 | 58 | uses: docker/setup-buildx-action@v3
|
46 | 59 | - name: Login to Docker Hub
|
| 60 | + if: ${{ steps.release.outputs.release_created }} |
47 | 61 | uses: docker/login-action@v3
|
48 | 62 | with:
|
49 | 63 | username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
50 | 64 | password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
51 | 65 |
|
52 | 66 | - name: Create custom Maven Settings.xml
|
53 |
| - uses: whelk-io/maven-settings-xml-action@v21 |
| 67 | + if: ${{ steps.release.outputs.release_created }} |
| 68 | + uses: whelk-io/maven-settings-xml-action@v22 |
54 | 69 | with:
|
55 | 70 | output_file: custom_maven_settings.xml
|
56 | 71 | servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
|
57 | 72 | - name: Set version with Maven
|
| 73 | + if: ${{ steps.release.outputs.release_created }} |
58 | 74 | run: ./mvnw -B versions:set -DprocessAllModules=true -DnewVersion=${{ steps.extract_tagname.outputs.tagname }}
|
59 | 75 | env:
|
60 | 76 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
61 | 77 | - name: Deploy with Maven to GitHub Packages and Docker Hub
|
| 78 | + if: ${{ steps.release.outputs.release_created }} |
62 | 79 | run: ./mvnw -B -s custom_maven_settings.xml -Pnative-image,release clean deploy
|
63 | 80 | env:
|
64 | 81 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
0 commit comments