release-maven #53
Workflow file for this run
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-maven | |
# IMAGE_NAME: string; The name of the module. | |
# 'indexdata/mod-harvester-admin' | |
env: | |
FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com' | |
CONTAINER_REGISTRY: 'ghcr.io' | |
IMAGE_NAME: 'indexdata/mod-harvester-admin' | |
OK_SESSION: 'session1' | |
on: | |
push: | |
tags: | |
# - '[vV][0-9]+.[0-9]+.[0-9]+' # i.e. release tag only | |
- '[vV][0-9]+.[0-9]+.[0-9]+*' # i.e. allow snapshot tag | |
jobs: | |
release-maven: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Gather some variables | |
run: | | |
echo "MODULE_NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV | |
echo "MODULE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> $GITHUB_ENV | |
- name: Report dependencies that are snaphots | |
run: mvn dependency:list | { grep -i snapshot || true; } | |
- name: Do Maven build | |
run: mvn clean install | |
- name: Ensure built ModuleDescriptor | |
run: | | |
if test -f "$MOD_DESCRIPTOR"; then | |
echo "Found $MOD_DESCRIPTOR" | |
echo "MODULE_DESCRIPTOR=$MOD_DESCRIPTOR" >> $GITHUB_ENV | |
else | |
echo "Could not find $MOD_DESCRIPTOR" | |
exit 1 | |
fi | |
env: | |
MOD_DESCRIPTOR: './target/ModuleDescriptor.json' | |
- name: Prepare okclient | |
run: git clone https://github.com/indexdata/okclient | |
- name: Ensure OK and FOLIO login | |
# So do not proceed with other workflow steps if not available. | |
run: | | |
source okclient/ok.sh | |
OK -S ${{ env.OK_SESSION }} \ | |
-h ${{ env.FOLIO_MD_REGISTRY }} \ | |
-t ${{ secrets.FOLIO_REGISTRY_TENANT }} \ | |
-u ${{ secrets.FOLIO_REGISTRY_USERNAME }} \ | |
-p ${{ secrets.FOLIO_REGISTRY_PASSWORD }} | |
OK -S ${{ env.OK_SESSION }} -x | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.CONTAINER_REGISTRY }} | |
username: ${{ github.ACTOR }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }} | |
labels: | | |
org.opencontainers.image.vendor=Index Data LLC | |
org.opencontainers.image.documentation=https://github.com/indexdata/localindices/tree/master/doc | |
- name: Build and publish Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Read ModuleDescriptor | |
id: moduleDescriptor | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ${{ env.MODULE_DESCRIPTOR }} | |
- name: Publish ModuleDescriptor to MD registry | |
run: | | |
source okclient/ok.sh | |
echo "Do login ..." | |
OK -S ${{ env.OK_SESSION }} \ | |
-h ${{ env.FOLIO_MD_REGISTRY }} \ | |
-t ${{ secrets.FOLIO_REGISTRY_TENANT }} \ | |
-u ${{ secrets.FOLIO_REGISTRY_USERNAME }} \ | |
-p ${{ secrets.FOLIO_REGISTRY_PASSWORD }} | |
echo "Post the MD and report the response status ..." | |
OK -S ${{ env.OK_SESSION }} _/proxy/modules \ | |
-X post -f ${{ env.MODULE_DESCRIPTOR }} | |
declare -n NAMEREF_STATUS=${{ env.OK_SESSION }}_HTTPStatus | |
echo "Response status: $NAMEREF_STATUS" | |
echo "Do logout ..." | |
OK -S ${{ env.OK_SESSION }} -x |