Skip to content

Publish new snapshot from main #4

Publish new snapshot from main

Publish new snapshot from main #4

#################################################################################
# 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
- bugfix/*
types:
- completed
workflow_dispatch:
# periodic build triggers are defined in run-all-tests.yml, which triggers this workflow
concurrency:
# cancel only running jobs on pull requests
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
secret-presence:
runs-on: ubuntu-latest
outputs:
DOCKER_HUB_TOKEN: ${{ steps.secret-presence.outputs.DOCKER_HUB_TOKEN }}
HAS_OSSRH: ${{ steps.secret-presence.outputs.HAS_OSSRH }}
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.ORG_OSSRH_USERNAME }}" ] &&
[ ! -z "${{ secrets.ORG_OSSRH_PASSWORD }}" ] && echo "HAS_OSSRH=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 }}
steps:
- uses: actions/checkout@v4
- 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" ]]; then
echo "VERSION=$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$RELEASE_VERSION_PATCH-$(date +"%Y%m%d")-SNAPSHOT" >> "$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 ]
# do not run on PR branches, do not run on releases
if: |
needs.secret-presence.outputs.HAS_OSSRH
uses: ./.github/workflows/trigger-maven-publish.yaml
secrets: inherit
with:
version: ${{ needs.determine-version.outputs.VERSION }}
publish-to-swaggerhub:
name: "Publish OpenAPI spec to Swaggerhub"
permissions:
contents: read
needs: [ secret-presence, determine-version ]
if: needs.secret-presence.outputs.HAS_SWAGGER
uses: ./.github/workflows/publish-swaggerhub.yaml
secrets: inherit
with:
downstream-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 }}