Version 5.5.0 #392
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
# | |
# Workflow: Build Release | |
# | |
name: Build Release | |
on: | |
# build release branch on push to release/* branch | |
# where * is expected to be a release version eg 2.1.4 | |
# trigger on push to release/<version> branch or push of v<version> tag on that branch | |
# when pushing a tagged commit, only one event triggers, for the tag | |
push: | |
branches: | |
- 'release/*' | |
tags: | |
- 'v*' | |
## manually build release branch, optionally release when version matches the branch | |
#workflow_dispatch: | |
# branches: | |
# - 'release/*' | |
# inputs: | |
# version: | |
# description: Copy version (eg "2.1.4") to trigger release. CAREFUL! | |
# required: false | |
# default: "" | |
jobs: | |
# verify what has been pushed and determine what to do | |
analyze: | |
name: Analyze | |
runs-on: ubuntu-latest | |
if: github.repository == 'hazelcast/hazelcast-csharp-client' | |
outputs: | |
todo: ${{ steps.analyze.outputs.todo}} # 'build' when pushing to release/2.1.4, 'release' when pushing v2.1.4 tag, otherwise 'nothing' | |
version: ${{ steps.analyze.outputs.version}} # 2.1.4 or 2.1.4-preview.1 - matches the branch/tag and the code | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 2 # needed to validate parents | |
- name: Analyze | |
id: analyze | |
shell: bash | |
run: | | |
set +e # don't die whenever a command returns non-zero $? | |
HZREF="${{ github.ref }}" | |
HZSHA="${{ github.sha }}" | |
echo "Triggered by $HZREF at $HZSHA" | |
HZBRANCH=${HZREF#refs/heads/} | |
if [ "$HZBRANCH" != "$HZREF" ]; then # it is a branch push | |
HZVERSION=${HZBRANCH#release/} | |
if [ "$HZVERSION" != "$HZBRANCH" ]; then # it is a release branch push | |
echo "Triggered by commit in version $HZVERSION release branch $HZBRANCH" | |
git fetch origin refs/tags/v$HZVERSION:refs/tags/v$HZVERSION >/dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "Tag v$HZVERSION does not exist, proceed with build" | |
# set step/job output | |
echo "todo=build" >> $GITHUB_OUTPUT | |
echo "version=$HZVERSION" >> $GITHUB_OUTPUT | |
else | |
HZTAGSHA=$(git rev-parse v$HZVERSION >/dev/null 2>&1) | |
if [ "$HZTAGSHA" != "${{ github.sha }}" ]; then | |
echo "::error::Tag v$HZVERSION exists, but on another commit ($HZTAGSHA)" | |
exit 1 | |
else | |
echo "Tag v$HZVERSION exists on this commit, nothing to do" | |
# set step/job output | |
echo "todo=nothing" >> $GITHUB_OUTPUT | |
echo "version=$HZVERSION" >> $GITHUB_OUTPUT | |
fi | |
fi | |
else | |
echo "::error::Triggered by commit in non-release branch $HZBRANCH" | |
exit 1 | |
fi | |
exit 0 | |
fi | |
HZTAG=${HZREF#refs/tags/} | |
if [ "$HZTAG" != "$HZREF" ]; then | |
HZVERSION=${HZTAG#v} | |
if [ "$HZVERSION" != "$HZTAG" ]; then # it is a version tag | |
echo "Triggered by version tag $HZTAG at $HZSHA" | |
git fetch origin refs/heads/release/$HZVERSION:refs/heads/release/$HZVERSION >/dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "::error::Branch release/$HZVERSION does not exist" | |
exit 1 | |
else | |
HZBRANCHSHA=$(git rev-parse origin/release/$HZVERSION 2>&1) | |
HZPARENTSHA=$(git rev-parse $HZSHA^) | |
if [ "$HZBRANCHSHA" != "$HZPARENTSHA" ]; then | |
echo "::error::Tag parent is not HEAD of release/$HZVERSION at $HZBRANCHSHA but $HZPARENTSHA" | |
exit 1 | |
else | |
echo "Tag parent is HEAD of release/$HZVERSION at $HZBRANCHSHA, proceed with release" | |
# set step/job output | |
echo "todo=release" >> $GITHUB_OUTPUT | |
echo "version=$HZVERSION" >> $GITHUB_OUTPUT | |
fi | |
fi | |
else | |
echo "::error::Triggered by non-version tag $HZTAG" | |
exit 1 | |
fi | |
exit 0 | |
fi | |
echo "::error::I am confused" | |
exit 1 | |
# get frameworks | |
get-fwks: | |
name: Get Frameworks | |
needs: analyze | |
uses: ./.github/workflows/get-frameworks.yml | |
secrets: inherit | |
# build and test the release | |
build-release: | |
name: Build Release / ${{ matrix.os }} | |
needs: [ analyze, get-fwks ] | |
if: needs.analyze.outputs.todo != 'nothing' | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest, windows-latest ] | |
uses: ./.github/workflows/build-and-test.yml | |
secrets: inherit | |
with: | |
os: ${{ matrix.os }} | |
fwks: ${{ needs.get-fwks.outputs[format('fwks-{0}', matrix.os)] }} | |
version: ${{ needs.analyze.outputs.version }} | |
release: true | |
# upload test coverage | |
upload-codecov: | |
name: Upload to Codecov | |
runs-on: ubuntu-latest | |
needs: [ analyze, build-release ] | |
steps: | |
# checkout the hazelcast/hazelcast-csharp-client repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# download the tests coverage artifacts | |
- name: Download tests coverage artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
# only net6.0 on windows-latest, that's what goes to codecov | |
path: ./temp/artifacts/test-coverage | |
name: 'Test-Coverage windows-latest-net6.0' | |
# publish to codecov - if build&test was successful | |
# see https://github.com/marketplace/actions/codecov | |
- name: Publish to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./temp/artifacts/test-coverage/cover-net6.0.xml | |
fail_ci_if_error: true | |
# publish the work-in-progress release | |
publish-wip: | |
name: Publish Work-In-Progress | |
runs-on: ubuntu-latest | |
needs: [ analyze, build-release ] | |
if: needs.analyze.outputs.todo == 'build' | |
steps: | |
# checkout the hazelcast/hazelcast-csharp-client repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Install our environment | |
- name: Install environment | |
uses: ./.github/actions/install | |
with: | |
os: ${{ inputs.os }} | |
dotnet: false | |
java: false | |
# checkout the hazelcast/hazelcast-csharp-client repository | |
# including all submodules, we are going to need them | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
submodules: true | |
# configure Git so that we can commit | |
- name: Configure repository | |
shell: bash | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions (Build Release)" | |
# prepare for artifacts | |
- name: Prepare for artifacts | |
shell: bash | |
run: | | |
mkdir ./temp | |
mkdir ./temp/gh-pages-patches | |
mkdir ./temp/tests | |
# download docs patch artifact | |
- name: Download docs patch artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: Docs-Patch | |
path: ./temp/gh-pages-patches | |
# verify downloads | |
- name: Verify downloads | |
shell: bash | |
run: | | |
echo "docs patch:" | |
ls ./temp/gh-pages-patches | |
# checkout documentation | |
- name: Checkout documentation | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
ref: gh-pages | |
path: ./temp/gh-pages | |
# configure Git so that we can commit | |
- name: Configure documentation repository | |
shell: bash | |
run: | | |
git -C ./temp/gh-pages config user.email "[email protected]" | |
git -C ./temp/gh-pages config user.name "GitHub Actions (Build Release)" | |
# publish 'dev' documentation | |
- name: Publish Documentation | |
shell: bash | |
run: | | |
echo "Apply patch" | |
cat temp/gh-pages-patches/*.patch | git -C ./temp/gh-pages am | |
echo "Push" | |
git -C ./temp/gh-pages push origin gh-pages | |
# publish the release | |
# if the build and tests were successful | |
publish-release: | |
name: Publish Release | |
runs-on: ubuntu-latest | |
needs: [ analyze, build-release ] | |
if: needs.analyze.outputs.todo == 'release' | |
steps: | |
# checkout the hazelcast/hazelcast-csharp-client repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Install our environment | |
- name: Install environment | |
uses: ./.github/actions/install | |
with: | |
os: ${{ inputs.os }} | |
dotnet: true | |
java: false | |
# checkout the hazelcast/hazelcast-csharp-client repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
submodules: true | |
# configure Git so that we can commit | |
- name: Configure repository | |
shell: bash | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions (Build Release)" | |
# checkout the devops repository for additional hz.ps1 commands (push-nuget...) | |
# "${{ github.token }} is scoped to the current repository, so if you want to checkout a different | |
# repository that is private you will need to provide your own PAT." | |
- name: Checkout devops | |
uses: actions/checkout@v3 | |
with: | |
repository: hazelcast/DevOps | |
ref: master | |
token: ${{ secrets.HAZELCAST_GITHUB_TOKEN_DEVOPS }} | |
path: ./build/devops | |
# prepare for artifacts | |
- name: Prepare for artifacts | |
shell: bash | |
run: | | |
mkdir ./temp | |
mkdir ./temp/output | |
mkdir ./temp/gh-pages-patches | |
# download nuget packages | |
- name: Download NuGet packages artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: NuGet-Packages | |
path: ./temp/output | |
# download docs patch artifact | |
- name: Download docs patch artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: Docs-Patch | |
path: ./temp/gh-pages-patches | |
# verify downloads | |
- name: Verify downloads | |
shell: bash | |
run: | | |
echo "packages:" | |
ls ./temp/output | |
echo "docs patch:" | |
ls ./temp/gh-pages-patches | |
# publish nuget package | |
- name: Publish NuGet packages | |
shell: pwsh | |
env: | |
NUGET_API_KEY: ${{ secrets.HAZELCAST_NUGET_API_KEY }} | |
run: | | |
./hz.ps1 -noRestore -localRestore push-nuget -yolo | |
# checkout documentation | |
- name: Checkout documentation | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
ref: gh-pages | |
path: ./temp/gh-pages | |
# configure Git so that we can commit | |
- name: Configure documentation repository | |
shell: bash | |
run: | | |
git -C ./temp/gh-pages config user.email "[email protected]" | |
git -C ./temp/gh-pages config user.name "GitHub Actions (Build Release)" | |
# publish documentation | |
- name: Publish Documentation | |
shell: bash | |
run: | | |
echo "Apply patch" | |
cat temp/gh-pages-patches/*.patch | git -C ./temp/gh-pages am | |
echo "Push" | |
git -C ./temp/gh-pages push origin gh-pages | |
# trash the release branch | |
- name: Close release branch | |
shell: bash | |
run: | | |
git push origin :release/${{ needs.analyze.outputs.version }} | |
# publish the release page, close the milestone | |
- name: Publish GitHub Release | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const scriptf = require('./.github/workflows/release-scripts.js') | |
const script = scriptf({github, context, core}) | |
const version = context.ref.substring(19) | |
await script.publishRelease(version) | |
await script.closeMilestone(version) |