Skip to content

Publish new snapshot from main #898

Publish new snapshot from main

Publish new snapshot from main #898

#################################################################################
# Copyright (c) 2023 ZF Friedrichshafen AG
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
#################################################################################
---
name: "Publish new snapshot"
run-name: "Publish new snapshot from ${{github.ref_name}}"
on:
workflow_run:
workflows: [ "Run-All-Tests" ]
branches:
- main
- release/*
types:
- completed
workflow_dispatch:
inputs:
dated_snapshot:
description: 'Dated snapshot version.'
default: false
type: boolean
# periodic build triggers are defined in run-all-tests.yml, which triggers this workflow
concurrency:
# cancel older running jobs on the same branch
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
secret-presence:
runs-on: ubuntu-latest
outputs:
DOCKER_HUB_TOKEN: ${{ steps.secret-presence.outputs.DOCKER_HUB_TOKEN }}
HAS_MVNCRED: ${{ steps.secret-presence.outputs.HAS_MVNCRED }}
HAS_SWAGGER: ${{ steps.secret-presence.outputs.HAS_SWAGGER }}
steps:
- name: Check whether secrets exist
id: secret-presence
run: |
[ ! -z "${{ secrets.DOCKER_HUB_TOKEN }}" ] && echo "DOCKER_HUB_TOKEN=true" >> $GITHUB_OUTPUT
[ ! -z "${{ secrets.ORG_GPG_PASSPHRASE }}" ] &&
[ ! -z "${{ secrets.ORG_GPG_PRIVATE_KEY }}" ] &&
[ ! -z "${{ secrets.CENTRAL_SONATYPE_TOKEN_USERNAME }}" ] &&
[ ! -z "${{ secrets.CENTRAL_SONATYPE_TOKEN_PASSWORD }}" ] && echo "HAS_MVNCRED=true" >> $GITHUB_OUTPUT
[ ! -z "${{ secrets.SWAGGERHUB_API_KEY }}" ] &&
[ ! -z "${{ secrets.SWAGGERHUB_USER }}" ] && echo "HAS_SWAGGER=true" >> $GITHUB_OUTPUT
exit 0
determine-version:
name: "Determine snapshot version to be published"
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.get-version.outputs.VERSION }}
DATED: ${{ steps.get-version.outputs.DATED }}
steps:
- uses: actions/checkout@v6
- name: "Get version"
id: get-version
run: |
IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<$(grep "version" gradle.properties | awk -F= '{print $2}')
if [[ "${{ github.event.workflow_run.event }}" == "schedule" || "${{ inputs.dated_snapshot }}" == "true" ]]; then
echo "VERSION=$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$RELEASE_VERSION_PATCH-$(date +"%Y%m%d")-SNAPSHOT" >> "$GITHUB_OUTPUT"
echo "DATED=true" >> "$GITHUB_OUTPUT"
else
echo "VERSION=$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$RELEASE_VERSION_PATCH-SNAPSHOT" >> "$GITHUB_OUTPUT"
fi
publish-docker-images:
name: "Create Docker Images"
needs: [ secret-presence, determine-version]
if: |
needs.secret-presence.outputs.DOCKER_HUB_TOKEN
permissions:
contents: write
uses: ./.github/workflows/trigger-docker-publish.yaml
secrets: inherit
with:
docker_tag: ${{ needs.determine-version.outputs.VERSION }}
publish-maven-artifacts:
name: "Publish artefacts to OSSRH Snapshots / MavenCentral"
permissions:
contents: read
needs: [ secret-presence, determine-version ]
if: |
needs.secret-presence.outputs.HAS_MVNCRED
uses: ./.github/workflows/trigger-maven-publish.yaml
secrets: inherit
with:
version: ${{ needs.determine-version.outputs.VERSION }}
publish-openapi-to-gh-pages:
name: "Publish OpenAPI UI spec GitHub Pages"
permissions:
contents: write
needs: [ secret-presence, determine-version ]
uses: ./.github/workflows/publish-openapi-ui.yml
secrets: inherit
with:
version: ${{ needs.determine-version.outputs.VERSION }}
latest: false
publish-latest-versioned-snapshot:
name: "Publish latest versioned snapshot in GitHub Pages"
runs-on: ubuntu-latest
permissions:
contents: write
needs: [ determine-version ]
if: ${{ needs.determine-version.outputs.DATED == 'true' }}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/publish-latest-versioned-snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ needs.determine-version.outputs.VERSION }}