From 19f93c5c7c45b9a4a11b36d772ef66d1a822755c Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Tue, 1 Apr 2025 18:37:57 -0700 Subject: [PATCH 1/7] ci: exit with error if development or production archive builds fail --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index e63fad27..677e9c6e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,7 @@ commands: - run: name: Generate dev and prod archives command: | + set -e ./scripts/archive.sh << parameters.artifact_dir >> $BUILD_VERSION retrieve-oidc-secrets: description: "Retrieves secrets from Slack" From 6078ccd3ab935e848c6238fbc912599fb4efeb34 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Tue, 1 Apr 2025 18:48:52 -0700 Subject: [PATCH 2/7] ci: exit with error from within the archive script not circle --- .circleci/config.yml | 1 - scripts/archive.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 677e9c6e..e63fad27 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,7 +63,6 @@ commands: - run: name: Generate dev and prod archives command: | - set -e ./scripts/archive.sh << parameters.artifact_dir >> $BUILD_VERSION retrieve-oidc-secrets: description: "Retrieves secrets from Slack" diff --git a/scripts/archive.sh b/scripts/archive.sh index af32154c..6395adbe 100755 --- a/scripts/archive.sh +++ b/scripts/archive.sh @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +set -eo # USAGE: # ./scripts/archive.sh From ec20fcd8e7b1b5103b735f26288c6dd3add185ac Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Tue, 1 Apr 2025 19:39:16 -0700 Subject: [PATCH 3/7] ci: use the most recent commit hash in changelog if no tag exists --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e63fad27..76c8c642 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -313,10 +313,10 @@ jobs: echo "Overwriting existing GitHub Release data; generating pre-release notes ..." LAST_SEMVER_TAG=$(git describe --tags --match 'v*.*.*' --abbrev=0 | cut -d"-" -f1) # When generating release notes, setting the target tag_name property to an existing tag has GitHub ignore the target_commitish property - # So, set it to some non-existent tag name for release-note-generating purposes. + # So, set the tag to the commit hash for release-note-generating purposes. # See https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#generate-release-notes-content-for-a-release--parameters # Note the following _does not change releases or tags_ - it only creates release notes, just like clicking "Generate Release Notes" on the GitHub Releases page. - CHANGELOG=$(curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_RELEASE_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/slackapi/slack-cli/releases/generate-notes -d "{\"tag_name\":\"does-not-exist\",\"target_commitish\":\"${TARGET}\",\"previous_tag_name\":\"${LAST_SEMVER_TAG}\"}" | jq .body) + CHANGELOG=$(curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_RELEASE_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/slackapi/slack-cli/releases/generate-notes -d "{\"tag_name\":\"${TARGET}\",\"target_commitish\":\"${TARGET}\",\"previous_tag_name\":\"${LAST_SEMVER_TAG}\"}" | jq .body) echo "Will use release notes: ${CHANGELOG}" BODY+="\"body\":$CHANGELOG}" echo "Updating existing GitHub pre-release ${RELEASE_ID} with ${BODY}" From cc496f30b5696844c42b7a9266cea201e31e1354 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Tue, 1 Apr 2025 20:32:49 -0700 Subject: [PATCH 4/7] ci: match prior feature builds when gathering the git version --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 76c8c642..3a00c64a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ commands: - run: name: Output BUILD_VERSION env var based on recent git tag and type of build command: | - BUILD_VERSION=$(git describe --tags --match 'v*.*.*' --exclude '*feature'); + BUILD_VERSION=$(git describe --tags --match 'v*.*.*'); echo "git tag-based BUILD_VERSION: $BUILD_VERSION" if [[ "<< parameters.release_ref >>" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then # if release tag starts with semver, then this is either a prod or feature build. use the release tag, then, as build version too. From 70e82233e3a7d8afcec6b83ab37f78abfc34a17e Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Tue, 1 Apr 2025 21:59:50 -0700 Subject: [PATCH 5/7] ci: share production compilation flags with the snapshot build --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3a00c64a..4ce5b5d4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -152,7 +152,7 @@ jobs: name: Run GoReleaser. Without actually publishing. command: | export LDFLAGS="-s -w -X 'github.com/slackapi/slack-cli/internal/pkg/version.Version=$BUILD_VERSION'" - make build-snapshot + make LDFLAGS="$LDFLAGS" build-snapshot - run: name: Show binaries are generated correctly command: ls -R ./dist From 3e3cf9f6035c0d51ff0c6ec3e0e8bbf17aa69a58 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Wed, 2 Apr 2025 16:02:30 -0700 Subject: [PATCH 6/7] revert: remove adjacent updates to ci for more focused changes --- .circleci/config.yml | 6 +++--- scripts/archive.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ce5b5d4..9bbcfc9a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ commands: - run: name: Output BUILD_VERSION env var based on recent git tag and type of build command: | - BUILD_VERSION=$(git describe --tags --match 'v*.*.*'); + BUILD_VERSION=$(git describe --tags --match 'v*.*.*' --exclude '*feature'); echo "git tag-based BUILD_VERSION: $BUILD_VERSION" if [[ "<< parameters.release_ref >>" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then # if release tag starts with semver, then this is either a prod or feature build. use the release tag, then, as build version too. @@ -313,10 +313,10 @@ jobs: echo "Overwriting existing GitHub Release data; generating pre-release notes ..." LAST_SEMVER_TAG=$(git describe --tags --match 'v*.*.*' --abbrev=0 | cut -d"-" -f1) # When generating release notes, setting the target tag_name property to an existing tag has GitHub ignore the target_commitish property - # So, set the tag to the commit hash for release-note-generating purposes. + # So, set it to some non-existent tag name for release-note-generating purposes. # See https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#generate-release-notes-content-for-a-release--parameters # Note the following _does not change releases or tags_ - it only creates release notes, just like clicking "Generate Release Notes" on the GitHub Releases page. - CHANGELOG=$(curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_RELEASE_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/slackapi/slack-cli/releases/generate-notes -d "{\"tag_name\":\"${TARGET}\",\"target_commitish\":\"${TARGET}\",\"previous_tag_name\":\"${LAST_SEMVER_TAG}\"}" | jq .body) + CHANGELOG=$(curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_RELEASE_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/slackapi/slack-cli/releases/generate-notes -d "{\"tag_name\":\"does-not-exist\",\"target_commitish\":\"${TARGET}\",\"previous_tag_name\":\"${LAST_SEMVER_TAG}\"}" | jq .body) echo "Will use release notes: ${CHANGELOG}" BODY+="\"body\":$CHANGELOG}" echo "Updating existing GitHub pre-release ${RELEASE_ID} with ${BODY}" diff --git a/scripts/archive.sh b/scripts/archive.sh index 6395adbe..af32154c 100755 --- a/scripts/archive.sh +++ b/scripts/archive.sh @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -set -eo + # USAGE: # ./scripts/archive.sh From 67bc2467055b180957c649d2d1aabdf51500c6aa Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Wed, 2 Apr 2025 16:08:56 -0700 Subject: [PATCH 7/7] style: avoid exporting ldflags used in the build snapshot step --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 80ce68e9..b4405482 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -151,7 +151,7 @@ jobs: - run: name: Run GoReleaser. Without actually publishing. command: | - export LDFLAGS="-s -w -X 'github.com/slackapi/slack-cli/internal/pkg/version.Version=$BUILD_VERSION'" + LDFLAGS="-s -w -X 'github.com/slackapi/slack-cli/internal/pkg/version.Version=$BUILD_VERSION'" make LDFLAGS="$LDFLAGS" build-snapshot - run: name: Show binaries are generated correctly