Perform Release #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Perform Release | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
description: Release Version | |
required: true | |
env: | |
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/campsite-booking | |
IMAGE_TAG: ${{ github.event.inputs.releaseVersion }} | |
jobs: | |
maven_release: | |
name: Maven Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
server-id: github | |
- name: Configure Git user | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions" | |
- name: Perform release & publish artifacts | |
run: ./mvnw -B release:prepare release:perform -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DskipTests -DskipITs | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
docker_image: | |
name: Docker Image | |
runs-on: ubuntu-latest | |
needs: [ maven_release ] | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
with: | |
ref: v${{ github.event.inputs.releaseVersion }} | |
- name: Build image | |
run: | | |
docker build --file container/Dockerfile --tag $IMAGE_NAME:$IMAGE_TAG . | |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:latest | |
- name: Log into registry | |
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
- name: Push image | |
run: | | |
docker push $IMAGE_NAME:$IMAGE_TAG | |
docker push $IMAGE_NAME:latest |