@cryptotaxi247 / netdata-1 / commits / d752b3e8b

Fix handling of pushing commits for release process. (#12359)

* Fix handling of pushing commits for release process. This works around the issue of pushing to protected branches from a actions workflow, and also makes the changelog generation it’s own step like it should be. * Fix typos in release workflow.

Austin S. Hemmelgarn committed Mar 10, 2022 at 15:15 UTC d752b3e8b74ecf9f384b3e72e1284826d4ceb72a
2 files changed +53 -66
.github/scripts/prepare-release-base.sh renamed
+12 -58
@@ -7,56 +7,6 @@ EVENT_NAME="${2}"
7 EVENT_TYPE="${3}"
8 EVENT_VERSION="${4}"
9
10 -##############################################################
11 -# Utility functions
12 -
13 -generate_changelog() {
14 - echo "::group::Generating changelog"
15 -
16 - if [ -n "${1}" ]; then
17 - OPTS="--future-release ${1}"
18 - fi
19 -
20 - # shellcheck disable=SC2086
21 - docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \
22 - --user "netdata" \
23 - --project "netdata" \
24 - --token "${GITHUB_TOKEN}" \
25 - --since-tag "v1.10.0" \
26 - --unreleased-label "**Next release**" \
27 - --no-issues \
28 - --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
29 - --max-issues 500 \
30 - --bug-labels IGNOREBUGS ${OPTS}
31 -
32 - echo "::endgroup::"
33 -}
34 -
35 -commit_changes() {
36 - branch="${1}"
37 - msg="${2}"
38 - tag="${3}"
39 -
40 - echo "::group::Committing changelog and version file and pushing changes."
41 -
42 - git checkout "${branch}"
43 - git add packaging/version CHANGELOG.md
44 - git commit -m "[ci skip] ${msg}"
45 - if [ -n "${tag}" ]; then
46 - git tag "${tag}"
47 - opts="--tags"
48 - fi
49 -
50 - if [ -n "${GITHUB_ACTIONS}" ]; then
51 - git push ${opts} "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "${branch}"
52 - else
53 - echo "Not pushing changes as we are not running in GitHub Actions."
54 - echo "Would have pushed ${branch} to origin, with additional options '${opts}'"
55 - fi
56 -
57 - echo "::endgroup::"
58 -}
59 -
10 ##############################################################
11 # Version validation functions
12
@@ -152,11 +102,12 @@ elif [ "${EVENT_NAME}" = 'schedule' ] || [ "${EVENT_TYPE}" = 'nightly' ]; then
102 LAST_TAG=$(git describe --abbrev=0 --tags)
103 COMMITS_SINCE_RELEASE=$(git rev-list "${LAST_TAG}"..HEAD --count)
104 NEW_VERSION="${LAST_TAG}-$((COMMITS_SINCE_RELEASE + 1))-nightly"
155 - generate_changelog "" || exit 1
105 echo "${NEW_VERSION}" > packaging/version || exit 1
157 - commit_changes master "Update changelog and version for nightly build: ${NEW_VERSION}."
106 echo "::set-output name=run::true"
107 + echo "::set-output name=message::Update changelog and version for nightly build: ${NEW_VERSION}."
108 echo "::set-output name=ref::master"
109 + echo "::set-output name=type::nightly"
110 + echo "::set-output name=branch::master"
111 elif [ "${EVENT_TYPE}" = 'patch' ] && [ "${EVENT_VERSION}" != "nightly" ]; then
112 echo "::notice::Preparing a patch release build."
113 check_version_format || exit 1
@@ -170,11 +121,12 @@ elif [ "${EVENT_TYPE}" = 'patch' ] && [ "${EVENT_VERSION}" != "nightly" ]; then
121 minor_matches || exit 1
122 major_matches || exit 1
123 check_newer_patch_number || exit 1
173 - generate_changelog "${EVENT_VERSION}" || exit 1
124 echo "${EVENT_VERSION}" > packaging/version || exit 1
175 - commit_changes "${branch_name}" "Patch release ${EVENT_VERSION}." "${EVENT_VERSION}" || exit 1
125 echo "::set-output name=run::true"
126 + echo "::set-output name=message::Patch release ${EVENT_VERSION}."
127 echo "::set-output name=ref::${EVENT_VERSION}"
128 + echo "::set-output name=type::release"
129 + echo "::set-output name=branch::${branch_name}"
130 elif [ "${EVENT_TYPE}" = 'minor' ] && [ "${EVENT_VERSION}" != "nightly" ]; then
131 echo "::notice::Preparing a minor release build."
132 check_version_format || exit 1
@@ -189,11 +141,12 @@ elif [ "${EVENT_TYPE}" = 'minor' ] && [ "${EVENT_VERSION}" != "nightly" ]; then
141 fi
142 git branch "${branch_name}"
143 git checkout "${branch_name}"
192 - generate_changelog "${EVENT_VERSION}" || exit 1
144 echo "${EVENT_VERSION}" > packaging/version || exit 1
194 - commit_changes "${branch_name}" "Minor release ${EVENT_VERSION}." "${EVENT_VERSION}" || exit 1
145 echo "::set-output name=run::true"
146 + echo "::set-output name=message::Minor release ${EVENT_VERSION}."
147 echo "::set-output name=ref::${EVENT_VERSION}"
148 + echo "::set-output name=type::release"
149 + echo "::set-output name=branch::${branch_name}"
150 elif [ "${EVENT_TYPE}" = 'major' ] && [ "${EVENT_VERSION}" != "nightly" ]; then
151 echo "::notice::Preparing a major release build."
152 check_version_format || exit 1
@@ -201,11 +154,12 @@ elif [ "${EVENT_TYPE}" = 'major' ] && [ "${EVENT_VERSION}" != "nightly" ]; then
154 patch_is_zero || exit 1
155 check_newer_major_version || exit 1
156 check_for_existing_tag || exit 1
204 - generate_changelog "${EVENT_VERSION}" || exit 1
157 echo "${EVENT_VERSION}" > packaging/version || exit 1
206 - commit_changes master "Major release ${EVENT_VERSION}." "${EVENT_VERSION}" || exit 1
158 echo "::set-output name=run::true"
159 + echo "::set-output name=message::Major release ${EVENT_VERSION}"
160 echo "::set-output name=ref::${EVENT_VERSION}"
161 + echo "::set-output name=type::release"
162 + echo "::set-output name=branch::master"
163 else
164 echo '::error::Unrecognized release type or invalid version.'
165 exit 1
.github/workflows/release.yml
+41 -8
@@ -32,22 +32,53 @@ jobs:
32 with:
33 fetch-depth: 0
34 submodules: recursive
35 - - name: Login to DockerHub # Needed to avoid ratelimits in the script we run in the next step.
36 - id: login
37 - uses: docker/login-action@v1
38 - with:
39 - username: ${{ secrets.DOCKER_HUB_USERNAME }}
40 - password: ${{ secrets.DOCKER_HUB_PASSWORD }}
35 - name: Prepare base ref
36 id: target
37 env:
38 GITHUB_TOKEN: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
39 run: >-
46 - .github/scripts/prepare-changelog.sh \
40 + .github/scripts/prepare-release-base.sh \
41 ${{ github.repository }} \
42 ${{ github.event_name }} \
43 ${{ github.event.inputs.type }} \
44 ${{ github.event.inputs.version }}
45 + - name: Generate Nightly Changleog
46 + id: nightly-changelog
47 + if: steps.target.outputs.run == 'true' && steps.target.outputs.type == 'nightly'
48 + uses: heinrichreimer/github-changelog-generator-action@v2.3
49 + with:
50 + bugLabels: IGNOREBUGS
51 + excludeLabels: "stale,duplicate,question,invalid,wontfix,discussion,no changelog"
52 + issues: false
53 + sinceTag: v1.10.0
54 + token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
55 + unreleasedLabel: "**Next release**"
56 + verbose: true
57 + - name: Generate Release Changelog
58 + id: release-changelog
59 + if: steps.target.outputs.run == 'true' && steps.target.outputs.type != 'nightly'
60 + uses: heinrichreimer/github-changelog-generator-action@v2.3
61 + with:
62 + bugLabels: IGNOREBUGS
63 + excludeLabels: "stale,duplicate,question,invalid,wontfix,discussion,no changelog"
64 + futureRelease: ${{ github.event.inputs.version }}
65 + issues: false
66 + sinceTag: v1.10.0
67 + token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
68 + unreleasedLabel: "**Next release**"
69 + verbose: true
70 + - name: Commit Changes
71 + id: commit
72 + if: steps.target.outputs.run == 'true'
73 + run: |
74 + git config user.name "netdatabot"
75 + git config user.email "bot@netdata.cloud"
76 + git add packaging/version CHANGELOG.md
77 + git commit -m "[ci skip] ${{ steps.target.outputs.message }}"
78 + if [ "${{ steps.target.outputs.type }}" != "nightly" ]; then
79 + git tag ${{ github.event.inputs.version }}
80 + fi
81 + git push https://${{ secrets.NETDATABOT_GITHUB_TOKEN }}@github.com/${{ github.repository }} ${{ steps.target.outputs.branch }}
82 - name: Failure Notification
83 uses: rtCamp/action-slack-notify@v2
84 env:
@@ -59,8 +90,10 @@ jobs:
90 SLACK_MESSAGE: |-
91 ${{ github.repository }}: Failed to prepare changelog.
92 Checkout: ${{ steps.checkout.outcome }}
62 - Login to DockerHub: ${{ steps.login.outcome }}
93 Prepare base ref: ${{ steps.target.outcome }}
94 + Generate nightly changelog: ${{ steps.nightly-changelog.outcome }}
95 + Generate release changelog: ${{ steps.release-changelog.outcome }}
96 + Commit changes: ${{ steps.commit.outcome }}
97 SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
98 if: failure()
99