From 66fb081c9276553d8e1ee66494444a44f01eb349 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 11 Jan 2023 19:23:47 +0000 Subject: [PATCH 1/7] ci: Ignore missing commit metadata in releases (for now) --- .github/workflows/release.yaml | 4 ++++ scripts/release.sh | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index db49a8f5a32a0..d1f581b3d5331 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,6 +36,10 @@ permissions: env: CODER_RELEASE: ${{ github.event.inputs.snapshot && 'false' || 'true' }} DRY_RUN: ${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && 'true' || 'false' }} + # Temporary workaround for commits on `main` without a PR, we can remove this + # once we ensure all commits for a release will have a PR. + # Also see scripts/release.sh. + CODER_IGNORE_MISSING_COMMIT_METADATA: "1" concurrency: ${{ github.workflow }}-${{ github.ref }} diff --git a/scripts/release.sh b/scripts/release.sh index bb2bb37d2685e..cff0567f7c07d 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -37,6 +37,17 @@ specified branch as the release commit. This will also set --dry-run. EOH } +# Temporary workaround for commits on `main` without a PR, we can remove this +# once we ensure all commits for a release will have a PR. +# Also see .github/workflow/release.yml. +export CODER_IGNORE_MISSING_COMMIT_METADATA=1 + +# Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way than via +# --branch. +if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then + log "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." +fi + branch=main draft=0 dry_run=0 From 9cc5d5ffcb6ca95826fe47ed18b526f3b45758f0 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 11 Jan 2023 19:28:11 +0000 Subject: [PATCH 2/7] ci: Warn in CI too --- .github/workflows/release.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d1f581b3d5331..2f3a264d47d1f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -130,6 +130,12 @@ jobs: ref=HEAD old_version="$(git describe --abbrev=0 "$ref^1")" + # Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way + # than via dry-run. + if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then + log "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." + fi + if [[ $DRY_RUN == true ]]; then # Allow dry-run of branches to pass. export CODER_IGNORE_MISSING_COMMIT_METADATA=1 From 62bdcf1f6dc84cf2c9cf64204bae77bccf1e606f Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 11 Jan 2023 19:29:27 +0000 Subject: [PATCH 3/7] ci: Use echo --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2f3a264d47d1f..938c4e610f8d6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -133,7 +133,7 @@ jobs: # Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way # than via dry-run. if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then - log "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." + echo "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." 1>&2 fi if [[ $DRY_RUN == true ]]; then From 55f12306d6846531332d9539ebb54f779593fa13 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 11 Jan 2023 19:42:45 +0000 Subject: [PATCH 4/7] ci: Turn ignore missing commit metadata into an input --- .github/workflows/release.yaml | 9 +++++---- scripts/release.sh | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 938c4e610f8d6..26ace5f58e235 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,6 +24,10 @@ on: description: Perform a dry-run release. type: boolean required: true + ignore_missing_commit_metadata: + description: Warning! This option disables the requirement that all commits have a PR. Not needed for dry_run. + type: boolean + default: false permissions: # Required to publish a release @@ -36,10 +40,7 @@ permissions: env: CODER_RELEASE: ${{ github.event.inputs.snapshot && 'false' || 'true' }} DRY_RUN: ${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && 'true' || 'false' }} - # Temporary workaround for commits on `main` without a PR, we can remove this - # once we ensure all commits for a release will have a PR. - # Also see scripts/release.sh. - CODER_IGNORE_MISSING_COMMIT_METADATA: "1" + CODER_IGNORE_MISSING_COMMIT_METADATA: ${{ github.event.inputs.ignore_missing_commit_metadata && '1' || '0' }} concurrency: ${{ github.workflow }}-${{ github.ref }} diff --git a/scripts/release.sh b/scripts/release.sh index cff0567f7c07d..b40f5ef430d95 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -37,15 +37,10 @@ specified branch as the release commit. This will also set --dry-run. EOH } -# Temporary workaround for commits on `main` without a PR, we can remove this -# once we ensure all commits for a release will have a PR. -# Also see .github/workflow/release.yml. -export CODER_IGNORE_MISSING_COMMIT_METADATA=1 - # Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way than via # --branch. if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then - log "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." + log "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled externally, we will ignore missing commit metadata." fi branch=main @@ -124,7 +119,9 @@ mapfile -t versions < <(gh api -H "Accept: application/vnd.github+json" /repos/c old_version=${versions[0]} # shellcheck source=scripts/release/check_commit_metadata.sh +trap 'log "Check commit metadata failed, you can try to set \"export CODER_IGNORE_MISSING_COMMIT_METADATA=1\" and try again, if you know what you are doing."' EXIT source "$SCRIPT_DIR/release/check_commit_metadata.sh" "$old_version" "$ref" +trap - EXIT new_version="$(execrelative ./release/tag_version.sh --dry-run --ref "$ref" --"$increment")" release_notes="$(execrelative ./release/generate_release_notes.sh --old-version "$old_version" --new-version "$new_version" --ref "$ref")" @@ -156,6 +153,9 @@ fi if ((dry_run)); then args+=(-F dry_run=true) fi +if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} == 1 ]]; then + args+=(-F ignore_missing_commit_metadata=true) +fi log gh workflow run release.yaml \ From 0334d91577a7c079fb9eb152207c8caa5bc81231 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 11 Jan 2023 19:45:54 +0000 Subject: [PATCH 5/7] Fix shellcheck line --- scripts/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.sh b/scripts/release.sh index b40f5ef430d95..57c9731afcd7f 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -118,8 +118,8 @@ fi mapfile -t versions < <(gh api -H "Accept: application/vnd.github+json" /repos/coder/coder/git/refs/tags -q '.[].ref | split("/") | .[2]' | grep '^v' | sort -r -V) old_version=${versions[0]} -# shellcheck source=scripts/release/check_commit_metadata.sh trap 'log "Check commit metadata failed, you can try to set \"export CODER_IGNORE_MISSING_COMMIT_METADATA=1\" and try again, if you know what you are doing."' EXIT +# shellcheck source=scripts/release/check_commit_metadata.sh source "$SCRIPT_DIR/release/check_commit_metadata.sh" "$old_version" "$ref" trap - EXIT From bf46382fde58416004ea354b24003dd313fe5107 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 11 Jan 2023 20:02:36 +0000 Subject: [PATCH 6/7] Fix workflow inputs --- .github/workflows/release.yaml | 2 +- scripts/release.sh | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 26ace5f58e235..17ec7f1b920f2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,7 +25,7 @@ on: type: boolean required: true ignore_missing_commit_metadata: - description: Warning! This option disables the requirement that all commits have a PR. Not needed for dry_run. + description: WARNING! This option disables the requirement that all commits have a PR. Not needed for dry_run. type: boolean default: false diff --git a/scripts/release.sh b/scripts/release.sh index 57c9731afcd7f..8dce7f91e3920 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -149,12 +149,19 @@ fi args=() if ((draft)); then args+=(-F draft=true) +else + args+=(-F draft=false) fi if ((dry_run)); then args+=(-F dry_run=true) -fi -if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} == 1 ]]; then - args+=(-F ignore_missing_commit_metadata=true) +else + args+=(-F dry_run=false) + + # We only set this on non-dry-run releases because it will show a + # warning in CI. + if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} == 1 ]]; then + args+=(-F ignore_missing_commit_metadata=true) + fi fi log From 5ce9dc90033b24dd60cf6024eaa3ec83e619f095 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 11 Jan 2023 20:05:00 +0000 Subject: [PATCH 7/7] Move tag+notes to an earlier step in workflow --- .github/workflows/release.yaml | 77 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 17ec7f1b920f2..557779a114a39 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -70,6 +70,45 @@ jobs: git config user.name "GitHub Actions Bot" git config user.email "" + - name: Create release tag and release notes + run: | + set -euo pipefail + ref=HEAD + old_version="$(git describe --abbrev=0 "$ref^1")" + + # Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way + # than via dry-run. + if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then + echo "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." 1>&2 + fi + + if [[ $DRY_RUN == true ]]; then + # Allow dry-run of branches to pass. + export CODER_IGNORE_MISSING_COMMIT_METADATA=1 + fi + + # Cache commit metadata. + . ./scripts/release/check_commit_metadata.sh "$old_version" "$ref" + + # Create new release tag (note that this tag is not pushed before + # release.sh is run). + version="$( + ./scripts/release/tag_version.sh \ + ${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \ + --ref "$ref" \ + --${{ github.event.inputs.increment }} + )" + + # Generate notes. + release_notes_file="$(mktemp -t release_notes.XXXXXX)" + ./scripts/release/generate_release_notes.sh --old-version "$old_version" --new-version "$version" --ref "$ref" >> "$release_notes_file" + echo CODER_RELEASE_NOTES_FILE="$release_notes_file" >> $GITHUB_ENV + + - name: Echo release notes + run: | + set -euo pipefail + cat "$CODER_RELEASE_NOTES_FILE" + - name: Docker Login uses: docker/login-action@v2 with: @@ -125,44 +164,6 @@ jobs: AC_CERTIFICATE_PASSWORD: ${{ secrets.AC_CERTIFICATE_PASSWORD }} AC_APIKEY_P8_BASE64: ${{ secrets.AC_APIKEY_P8_BASE64 }} - - name: Create release tag and release notes - run: | - set -euo pipefail - ref=HEAD - old_version="$(git describe --abbrev=0 "$ref^1")" - - # Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way - # than via dry-run. - if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then - echo "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." 1>&2 - fi - - if [[ $DRY_RUN == true ]]; then - # Allow dry-run of branches to pass. - export CODER_IGNORE_MISSING_COMMIT_METADATA=1 - fi - - # Cache commit metadata. - . ./scripts/release/check_commit_metadata.sh "$old_version" "$ref" - - # Create new release tag. - version="$( - ./scripts/release/tag_version.sh \ - ${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \ - --ref "$ref" \ - --${{ github.event.inputs.increment }} - )" - - # Generate notes. - release_notes_file="$(mktemp -t release_notes.XXXXXX)" - ./scripts/release/generate_release_notes.sh --old-version "$old_version" --new-version "$version" --ref "$ref" >> "$release_notes_file" - echo CODER_RELEASE_NOTES_FILE="$release_notes_file" >> $GITHUB_ENV - - - name: Echo release notes - run: | - set -euo pipefail - cat "$CODER_RELEASE_NOTES_FILE" - - name: Build binaries run: | set -euo pipefail