diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2022-03-10 15:15:55 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-10 15:15:55 -0500 |
commit | d752b3e8b74ecf9f384b3e72e1284826d4ceb72a (patch) | |
tree | 73b1419730ea3545ca1c93e545c332937c80a071 | |
parent | 4116afa0756f0c9bb7fad8ffa4a0a2b449ce9875 (diff) |
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.
-rwxr-xr-x | .github/scripts/prepare-release-base.sh (renamed from .github/scripts/prepare-changelog.sh) | 70 | ||||
-rw-r--r-- | .github/workflows/release.yml | 49 |
2 files changed, 53 insertions, 66 deletions
diff --git a/.github/scripts/prepare-changelog.sh b/.github/scripts/prepare-release-base.sh index a52ad273eb..33235946f2 100755 --- a/.github/scripts/prepare-changelog.sh +++ b/.github/scripts/prepare-release-base.sh @@ -8,56 +8,6 @@ EVENT_TYPE="${3}" EVENT_VERSION="${4}" ############################################################## -# Utility functions - -generate_changelog() { - echo "::group::Generating changelog" - - if [ -n "${1}" ]; then - OPTS="--future-release ${1}" - fi - - # shellcheck disable=SC2086 - docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \ - --user "netdata" \ - --project "netdata" \ - --token "${GITHUB_TOKEN}" \ - --since-tag "v1.10.0" \ - --unreleased-label "**Next release**" \ - --no-issues \ - --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \ - --max-issues 500 \ - --bug-labels IGNOREBUGS ${OPTS} - - echo "::endgroup::" -} - -commit_changes() { - branch="${1}" - msg="${2}" - tag="${3}" - - echo "::group::Committing changelog and version file and pushing changes." - - git checkout "${branch}" - git add packaging/version CHANGELOG.md - git commit -m "[ci skip] ${msg}" - if [ -n "${tag}" ]; then - git tag "${tag}" - opts="--tags" - fi - - if [ -n "${GITHUB_ACTIONS}" ]; then - git push ${opts} "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "${branch}" - else - echo "Not pushing changes as we are not running in GitHub Actions." - echo "Would have pushed ${branch} to origin, with additional options '${opts}'" - fi - - echo "::endgroup::" -} - -############################################################## # Version validation functions check_version_format() { @@ -152,11 +102,12 @@ elif [ "${EVENT_NAME}" = 'schedule' ] || [ "${EVENT_TYPE}" = 'nightly' ]; then LAST_TAG=$(git describe --abbrev=0 --tags) COMMITS_SINCE_RELEASE=$(git rev-list "${LAST_TAG}"..HEAD --count) NEW_VERSION="${LAST_TAG}-$((COMMITS_SINCE_RELEASE + 1))-nightly" - generate_changelog "" || exit 1 echo "${NEW_VERSION}" > packaging/version || exit 1 - commit_changes master "Update changelog and version for nightly build: ${NEW_VERSION}." echo "::set-output name=run::true" + echo "::set-output name=message::Update changelog and version for nightly build: ${NEW_VERSION}." echo "::set-output name=ref::master" + echo "::set-output name=type::nightly" + echo "::set-output name=branch::master" elif [ "${EVENT_TYPE}" = 'patch' ] && [ "${EVENT_VERSION}" != "nightly" ]; then echo "::notice::Preparing a patch release build." check_version_format || exit 1 @@ -170,11 +121,12 @@ elif [ "${EVENT_TYPE}" = 'patch' ] && [ "${EVENT_VERSION}" != "nightly" ]; then minor_matches || exit 1 major_matches || exit 1 check_newer_patch_number || exit 1 - generate_changelog "${EVENT_VERSION}" || exit 1 echo "${EVENT_VERSION}" > packaging/version || exit 1 - commit_changes "${branch_name}" "Patch release ${EVENT_VERSION}." "${EVENT_VERSION}" || exit 1 echo "::set-output name=run::true" + echo "::set-output name=message::Patch release ${EVENT_VERSION}." echo "::set-output name=ref::${EVENT_VERSION}" + echo "::set-output name=type::release" + echo "::set-output name=branch::${branch_name}" elif [ "${EVENT_TYPE}" = 'minor' ] && [ "${EVENT_VERSION}" != "nightly" ]; then echo "::notice::Preparing a minor release build." check_version_format || exit 1 @@ -189,11 +141,12 @@ elif [ "${EVENT_TYPE}" = 'minor' ] && [ "${EVENT_VERSION}" != "nightly" ]; then fi git branch "${branch_name}" git checkout "${branch_name}" - generate_changelog "${EVENT_VERSION}" || exit 1 echo "${EVENT_VERSION}" > packaging/version || exit 1 - commit_changes "${branch_name}" "Minor release ${EVENT_VERSION}." "${EVENT_VERSION}" || exit 1 echo "::set-output name=run::true" + echo "::set-output name=message::Minor release ${EVENT_VERSION}." echo "::set-output name=ref::${EVENT_VERSION}" + echo "::set-output name=type::release" + echo "::set-output name=branch::${branch_name}" elif [ "${EVENT_TYPE}" = 'major' ] && [ "${EVENT_VERSION}" != "nightly" ]; then echo "::notice::Preparing a major release build." check_version_format || exit 1 @@ -201,11 +154,12 @@ elif [ "${EVENT_TYPE}" = 'major' ] && [ "${EVENT_VERSION}" != "nightly" ]; then patch_is_zero || exit 1 check_newer_major_version || exit 1 check_for_existing_tag || exit 1 - generate_changelog "${EVENT_VERSION}" || exit 1 echo "${EVENT_VERSION}" > packaging/version || exit 1 - commit_changes master "Major release ${EVENT_VERSION}." "${EVENT_VERSION}" || exit 1 echo "::set-output name=run::true" + echo "::set-output name=message::Major release ${EVENT_VERSION}" echo "::set-output name=ref::${EVENT_VERSION}" + echo "::set-output name=type::release" + echo "::set-output name=branch::master" else echo '::error::Unrecognized release type or invalid version.' exit 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e5e105b7a..3dccb5b25f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,22 +32,53 @@ jobs: with: fetch-depth: 0 submodules: recursive - - name: Login to DockerHub # Needed to avoid ratelimits in the script we run in the next step. - id: login - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - name: Prepare base ref id: target env: GITHUB_TOKEN: ${{ secrets.NETDATABOT_GITHUB_TOKEN }} run: >- - .github/scripts/prepare-changelog.sh \ + .github/scripts/prepare-release-base.sh \ ${{ github.repository }} \ ${{ github.event_name }} \ ${{ github.event.inputs.type }} \ ${{ github.event.inputs.version }} + - name: Generate Nightly Changleog + id: nightly-changelog + if: steps.target.outputs.run == 'true' && steps.target.outputs.type == 'nightly' + uses: heinrichreimer/github-changelog-generator-action@v2.3 + with: + bugLabels: IGNOREBUGS + excludeLabels: "stale,duplicate,question,invalid,wontfix,discussion,no changelog" + issues: false + sinceTag: v1.10.0 + token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }} + unreleasedLabel: "**Next release**" + verbose: true + - name: Generate Release Changelog + id: release-changelog + if: steps.target.outputs.run == 'true' && steps.target.outputs.type != 'nightly' + uses: heinrichreimer/github-changelog-generator-action@v2.3 + with: + bugLabels: IGNOREBUGS + excludeLabels: "stale,duplicate,question,invalid,wontfix,discussion,no changelog" + futureRelease: ${{ github.event.inputs.version }} + issues: false + sinceTag: v1.10.0 + token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }} + unreleasedLabel: "**Next release**" + verbose: true + - name: Commit Changes + id: commit + if: steps.target.outputs.run == 'true' + run: | + git config user.name "netdatabot" + git config user.email "bot@netdata.cloud" + git add packaging/version CHANGELOG.md + git commit -m "[ci skip] ${{ steps.target.outputs.message }}" + if [ "${{ steps.target.outputs.type }}" != "nightly" ]; then + git tag ${{ github.event.inputs.version }} + fi + git push https://${{ secrets.NETDATABOT_GITHUB_TOKEN }}@github.com/${{ github.repository }} ${{ steps.target.outputs.branch }} - name: Failure Notification uses: rtCamp/action-slack-notify@v2 env: @@ -59,8 +90,10 @@ jobs: SLACK_MESSAGE: |- ${{ github.repository }}: Failed to prepare changelog. Checkout: ${{ steps.checkout.outcome }} - Login to DockerHub: ${{ steps.login.outcome }} Prepare base ref: ${{ steps.target.outcome }} + Generate nightly changelog: ${{ steps.nightly-changelog.outcome }} + Generate release changelog: ${{ steps.release-changelog.outcome }} + Commit changes: ${{ steps.commit.outcome }} SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} if: failure() |