Skip to content

Release

Release #13

Workflow file for this run

# yamllint disable rule:line-length
---
name: Release
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
build:
permissions:
packages: write
contents: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.versioncheck.outputs.version }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: "temurin"
- name: Determine the version
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
id: versioncheck
- name: Exit when workflow_dispatch is triggered, and the version does not contain SNAPSHOT in it's name
run: |
echo "Only SNAPSHOT releases can be triggered with the workflow_dispatch"
exit 1
if: github.event_name == 'workflow_dispatch' && ( !endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT'))
- name: Exit when a production build is triggered, and the github tag is not the same as the version in pom.xml
run: |
echo echo "Project version ${{ steps.versioncheck.outputs.version }} does not match git tag ${{ github.ref_name }}"
exit 1
if: github.event_name != 'workflow_dispatch' && steps.versioncheck.outputs.version != github.ref_name
- name: Set up JDK 21 for snapshots
uses: actions/setup-java@v4
with:
java-version: 21
distribution: "temurin"
cache: "maven"
server-id: openconext-snapshots
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
if: ( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT'))
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: "temurin"
cache: "maven"
server-id: openconext-releases
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
if: ${{!( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) }}
- name: install node
uses: dcodeIO/setup-node-nvm@master
with:
node-version: 14
- name: Deploy with Maven
run: mvn --batch-mode deploy -DskipTests
env:
MAVEN_USERNAME: ${{ secrets.BUILD_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.BUILD_PASSWORD }}
- name: Upload the produced artefacts
uses: actions/upload-artifact@v4
with:
name: brokerbuilds
path: |
client/public/
server/target/*.jar
retention-days: 1
- name: Codecov
uses: codecov/[email protected]
- name: Create release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: true
release_name: Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
body: |
${{ steps.changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ github.token }}
if: github.event_name != 'workflow_dispatch'
dockerbuild:
permissions: write-all
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- image: ghcr.io/SURFnet/student-mobility-broker/brokerclient
app: client
- image: ghcr.io/SURFnet/student-mobility-broker/brokerserver
app: server
steps:
- uses: actions/checkout@v4
- name: Download the previous produced artefacts
uses: actions/download-artifact@v4
with:
name: brokerbuilds
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set docker labels and tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
flavor: |
latest=false
tags: |
type=ref,event=tag
type=raw,event=tag,value=latest
type=raw,event=workflow_dispatch,value=snapshot
type=semver,pattern={{version}},value=${{ needs.build.outputs.version }}
type=sha
- name: Build and push the ${{ matrix.app }} image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.app }}
file: ${{ matrix.app }}/docker/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}