Skip to content

Publish and release #27

Publish and release

Publish and release #27

#
# Copyright (c) 2021 - for information on the respective copyright owner
# see the NOTICE file and/or the repository https://github.com/carbynestack/common.
#
# SPDX-License-Identifier: Apache-2.0
#
name: Publish and release
on:
workflow_run:
workflows: [ "Artifacts" ]
branches:
- master
types:
- completed
workflow_dispatch:
jobs:
prepare:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-20.04
outputs:
VERSION: "${{ steps.maven-project.outputs.version }}-${{ github.run_id }}-${{ github.run_number }}-${{ steps.short-sha.outputs.sha }}"
steps:
- name: Parse short sha
uses: benjlevesque/short-sha@v1.2
id: short-sha
- uses: actions/checkout@v2
- name: Get Maven project version
run: echo ::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
id: maven-project
draft-release:
runs-on: ubuntu-20.04
needs: [ prepare ]
env:
VERSION: "${{ needs.prepare.outputs.VERSION }}"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Retrieve license obligation resources
run: |
find . -regex '.*3RD-PARTY-LICENSES' -type d -not -regex '.*target.*' | \
awk '{split($0,a,"3RD-PARTY-LICENSES"); system("cd " $0 " && find . -type d -maxdepth 1 -not -path . | zip -r@ \"$(cat module.name)-3rd-party-copyrights\" && cd -")}'
find . -iname origin.src -regex '.*3RD-PARTY-LICENSES.*' -not -regex '.*target.*' | \
awk '{ \
split($0,a,"3RD-PARTY-LICENSES"); \
split(a[2],b,"/"); \
system("xargs < " $0 " curl --create-dirs -Lo " a[1] "/3RD-PARTY-LICENSES/sources/" b[2] ".zip " $2)}' && \
find -regex '.*3RD-PARTY-LICENSES/sources$' | awk '{system("zip -jr " $0 "/../$(cat "$0"/../module.name)-3rd-party-sources.zip " $0)}'
mkdir -p license-obligations && mv `find . -name "*-3rd-party-*.zip"` license-obligations/
- name: Generate change log
run: |
chmod +x .github/scripts/generate-changelog.sh
./.github/scripts/generate-changelog.sh
- name: Create release tag
run: |
git tag ${{ env.VERSION }}
git push --tags
- name: Create draft
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
draft: true
bodyFile: /tmp/cs.repository-changelog.${{ env.VERSION }}
artifacts: "license-obligations/*"
publish:
runs-on: ubuntu-20.04
needs: [ prepare,draft-release ]
env:
VERSION: "${{ needs.prepare.outputs.VERSION }}"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Setting up Github Package Repository as Maven Repository
uses: s4u/maven-settings-action@v2
with:
githubServer: false
servers: |
[{
"id": "github",
"username": "${{ secrets.GHPR_USERNAME }}",
"password": "${{ secrets.GHPR_TOKEN }}"
}]
- name: Update Maven project version
run: mvn versions:set -DnewVersion=${{ env.VERSION }} -DprocessAllModules -DgenerateBackupPoms=false
- name: Publish SNAPSHOT version to GitHub Packages
run: mvn deploy -Dskip.tests --batch-mode --no-transfer-progress
- name: Publish release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
allowUpdates: true
draft: false
omitBodyDuringUpdate: true