|
| 1 | +# ************************************************************************** |
| 2 | +# Copyright (c) Cloud Native Foundation. |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | +# ************************************************************************** |
| 5 | + |
| 6 | +name: Release |
| 7 | + |
| 8 | +on: |
| 9 | + create: |
| 10 | + tags: |
| 11 | + - v* |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + psgallery-publish: |
| 16 | + name: Release CloudEvents.Sdk Module |
| 17 | + runs-on: "ubuntu-latest" |
| 18 | + env: |
| 19 | + OUTPUT_DIR: release |
| 20 | + CHANGE_LOG_FILE_NAME: RELEASE_CHANGELOG.md |
| 21 | + |
| 22 | + timeout-minutes: 10 |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Check out code |
| 26 | + uses: actions/checkout@v2 |
| 27 | + |
| 28 | + - name: Build and Test |
| 29 | + shell: pwsh |
| 30 | + run: ./build.ps1 -OutputDir $env:OUTPUT_DIR -TestsType all -ExitProcess |
| 31 | + |
| 32 | + - name: Publish to PSGallery |
| 33 | + shell: pwsh |
| 34 | + run: ./publish.ps1 -ModuleReleaseDir $env:OUTPUT_DIR -NuGetApiKey ${{ secrets.CLOUDEVENTS_SDK_PUBLISHER_API_KEY }} |
| 35 | + |
| 36 | + - name: Create CHANGELOG |
| 37 | + env: |
| 38 | + IMAGE: quay.io/git-chglog/git-chglog |
| 39 | + # https://quay.io/repository/git-chglog/git-chglog from tag v0.14.2 |
| 40 | + IMAGE_SHA: 998e89dab8dd8284cfff5f8cfb9e9af41fe3fcd4671f2e86a180e453c20959e3 |
| 41 | + run: | |
| 42 | + # generate CHANGELOG for this Github release tag only |
| 43 | + docker run --rm -v $PWD:/workdir ${IMAGE}@sha256:${IMAGE_SHA} -o ${CHANGE_LOG_FILE_NAME} $(basename "${{ github.ref }}" ) |
| 44 | +
|
| 45 | + - name: Create Github Release |
| 46 | + env: |
| 47 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + run: gh release create $(basename "${{ github.ref }}") -F ${CHANGE_LOG_FILE_NAME} |
| 49 | + |
| 50 | + changelog-pull-request: |
| 51 | + needs: psgallery-publish |
| 52 | + name: Create CHANGELOG PR |
| 53 | + runs-on: ubuntu-latest |
| 54 | + continue-on-error: true |
| 55 | + env: |
| 56 | + CHANGE_LOG_FILE_NAME: CHANGELOG.md |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@v2 |
| 61 | + with: |
| 62 | + # for changelog |
| 63 | + fetch-depth: 0 |
| 64 | + ref: "main" |
| 65 | + |
| 66 | + - name: Create CHANGELOG commit |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + IMAGE: quay.io/git-chglog/git-chglog |
| 70 | + # https://quay.io/repository/git-chglog/git-chglog from tag v0.14.2 |
| 71 | + IMAGE_SHA: 998e89dab8dd8284cfff5f8cfb9e9af41fe3fcd4671f2e86a180e453c20959e3 |
| 72 | + run: | |
| 73 | + # update CHANGELOG.md |
| 74 | + docker run --rm -v $PWD:/workdir ${IMAGE}@sha256:${IMAGE_SHA} -o ${CHANGE_LOG_FILE_NAME} |
| 75 | +
|
| 76 | + git config user.email "${{ github.actor }}@users.noreply.github.com" |
| 77 | + git config user.name "${{ github.actor }}" |
| 78 | + git add ${CHANGE_LOG_FILE_NAME} |
| 79 | + git commit -m "Update CHANGELOG for $(basename ${{ github.ref }})" |
| 80 | +
|
| 81 | + - name: Create Pull Request |
| 82 | + uses: peter-evans/create-pull-request@v3 |
| 83 | + with: |
| 84 | + delete-branch: true |
| 85 | + title: "Update CHANGELOG" |
| 86 | + body: | |
| 87 | + Update CHANGELOG.md for new release |
| 88 | +
|
0 commit comments