Release (Github Package Registry) #9
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: Release (Github Package Registry) | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- tjenestespesifikasjoner/** | |
jobs: | |
release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set release tag | |
run: | | |
TAG_NAME="$(TZ="Europe/Oslo" date +%Y.%m.%d-%H.%M).$(echo $GITHUB_SHA | cut -c 1-12)" | |
echo "RELEASE_TAG=tjenestespesifikasjoner-${TAG_NAME}" >> $GITHUB_ENV | |
- name: Set changelog | |
# (Escape newlines see https://github.com/actions/create-release/issues/25) | |
run: | | |
text="$(git --no-pager log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")" | |
text="${text//$'%'/%25}" | |
text="${text//$'\n'/%0A}" | |
text="${text//$'\r'/%0D}" | |
echo "CHANGELOG=$text" >> $GITHUB_ENV | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
cache: maven | |
- name: Deploy artifacts to github maven repository | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mvn -f tjenestespesifikasjoner -B versions:set -DnewVersion="$RELEASE_TAG" | |
mvn -f tjenestespesifikasjoner -B versions:commit | |
echo "Running release" | |
mvn -f tjenestespesifikasjoner -B --settings tjenestespesifikasjoner/maven-settings.xml deploy -Dmaven.wagon.http.pool=false | |
- name: Create Release | |
id: create_release | |
uses: elgohr/Github-Release-Action@v5 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
title: ${{ env.RELEASE_TAG }} |