|
| 1 | +# SPDX-FileCopyrightText: 2021 Alliander N.V. |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +name: Release Project |
| 6 | + |
| 7 | +on: |
| 8 | + release: |
| 9 | + types: [released] |
| 10 | + |
| 11 | +jobs: |
| 12 | + push_to_registry: |
| 13 | + name: Build and publish |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v2 |
| 18 | + - name: Set up Docker Buildx |
| 19 | + id: buildx |
| 20 | + uses: docker/setup-buildx-action@v1 |
| 21 | + - name: Login to Docker Hub |
| 22 | + uses: docker/login-action@v1 |
| 23 | + with: |
| 24 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 25 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 26 | + - name: Cache Docker Register |
| 27 | + uses: actions/cache@v2 |
| 28 | + with: |
| 29 | + path: /tmp/.buildx-cache |
| 30 | + key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }} |
| 31 | + - name: Cache Maven packages |
| 32 | + |
| 33 | + with: |
| 34 | + path: ~/.m2 |
| 35 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 36 | + restore-keys: ${{ runner.os }}-m2 |
| 37 | + |
| 38 | + - name: Extract tag name |
| 39 | + id: extract_tagname |
| 40 | + shell: bash |
| 41 | + # Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>. |
| 42 | + run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})" |
| 43 | + - name: Set up JDK 1.11 |
| 44 | + |
| 45 | + with: |
| 46 | + distribution: 'zulu' |
| 47 | + java-version: '11' |
| 48 | + |
| 49 | + - name: Create custom Maven Settings.xml |
| 50 | + uses: whelk-io/maven-settings-xml-action@v20 |
| 51 | + with: |
| 52 | + output_file: custom_maven_settings.xml |
| 53 | + servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]' |
| 54 | + - name: Set version with Maven |
| 55 | + run: ./mvnw -B versions:set -DprocessAllModules=true -DnewVersion=${{ steps.extract_tagname.outputs.tagname }} |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + - name: Deploy with Maven to GitHub Packages and Docker Hub |
| 59 | + run: ./mvnw -B -s custom_maven_settings.xml -Prelease,native clean deploy |
| 60 | + env: |
| 61 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments