From 1a8afb332fdf735eaaf72c4ce12f82dffa95f0e7 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 16:33:07 -0700 Subject: [PATCH 01/10] Debug publish script. --- .github/workflows/release.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bdd249a..bb5946e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -71,11 +71,11 @@ jobs: # 2. to the main branch # 3. with the label 'release:publish', and # 4. the title prefix 'chore: Release '. - if: > - github.event.pull_request.merged && - github.ref == 'main' && - contains(github.event.pull_request.labels.*.name, 'release:publish') && - startsWith(github.event.pull_request.title, 'chore: Release ') + # if: > + # github.event.pull_request.merged && + # github.ref == 'main' && + # contains(github.event.pull_request.labels.*.name, 'release:publish') && + # startsWith(github.event.pull_request.title, 'chore: Release ') runs-on: ubuntu-latest From 757539d6f4d5798ccedd074195ead9b3e83680e3 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 16:35:21 -0700 Subject: [PATCH 02/10] Cleanup release condition. --- .github/workflows/release.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bb5946e..d2f39af 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,9 +25,10 @@ jobs: # To publish a release, merge the release PR with the label 'release:publish'. # To stage a release without publishing it, manually invoke the workflow. # . or apply the 'release:stage' label to a PR. - if: (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'release:publish')) || + if: > + (github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'release:publish')) || github.event.workflow_dispatch || - contains(github.event.pull_request.labels.*.name, 'release:stage') + (!github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'release:stage')) runs-on: ubuntu-latest From 7daf1655d3a63fe3b3f7119a51724271ccb62192 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 16:37:35 -0700 Subject: [PATCH 03/10] More diagnostics. --- .github/scripts/generate_changelog.sh | 1 + .github/scripts/publish_preflight_check.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/scripts/generate_changelog.sh b/.github/scripts/generate_changelog.sh index c4c77f6..598888e 100755 --- a/.github/scripts/generate_changelog.sh +++ b/.github/scripts/generate_changelog.sh @@ -16,6 +16,7 @@ set -e set -u +set -x function printChangelog() { local TITLE=$1 diff --git a/.github/scripts/publish_preflight_check.sh b/.github/scripts/publish_preflight_check.sh index 970355a..0802c9f 100755 --- a/.github/scripts/publish_preflight_check.sh +++ b/.github/scripts/publish_preflight_check.sh @@ -24,6 +24,7 @@ set -e set -u +set -x function echo_info() { local MESSAGE=$1 From 694906b62dd511f15f7805877b8907fb1488c03f Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 16:38:14 -0700 Subject: [PATCH 04/10] Let's not publish. --- .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 d2f39af..bd6bb02 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -112,4 +112,4 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: user: firebase - password: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file + password: "abc" \ No newline at end of file From 7456e7f6762e8bbee688440326e47e5182c667c1 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 16:56:14 -0700 Subject: [PATCH 05/10] Try to fix preflight. --- .github/scripts/generate_changelog.sh | 8 ++++---- .github/scripts/publish_preflight_check.sh | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/scripts/generate_changelog.sh b/.github/scripts/generate_changelog.sh index 598888e..71f2b93 100755 --- a/.github/scripts/generate_changelog.sh +++ b/.github/scripts/generate_changelog.sh @@ -40,14 +40,14 @@ fi LAST_TAG=`git describe --tags $(git rev-list --tags --max-count=1) 2> /dev/null` || true if [[ -z "${LAST_TAG}" ]]; then - echo "[INFO] No tags found. Including all commits up to ${GITHUB_SHA}." + echo_info "No tags found. Including all commits up to ${GITHUB_SHA}." VERSION_RANGE="${GITHUB_SHA}" else - echo "[INFO] Last release tag: ${LAST_TAG}." + echo_info "Last release tag: ${LAST_TAG}." COMMIT_SHA=`git show-ref -s ${LAST_TAG}` - echo "[INFO] Last release commit: ${COMMIT_SHA}." + echo_info "Last release commit: ${COMMIT_SHA}." VERSION_RANGE="${COMMIT_SHA}..${GITHUB_SHA}" - echo "[INFO] Including all commits in the range ${VERSION_RANGE}." + echo_info "Including all commits in the range ${VERSION_RANGE}." fi echo "" diff --git a/.github/scripts/publish_preflight_check.sh b/.github/scripts/publish_preflight_check.sh index 0802c9f..d7e8a22 100755 --- a/.github/scripts/publish_preflight_check.sh +++ b/.github/scripts/publish_preflight_check.sh @@ -135,6 +135,10 @@ echo_info "Checking release tag" echo_info "--------------------------------------------" echo_info "" +echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* >---" +git fetch --depth=1 origin +refs/tags/*:refs/tags/* +echo "" + readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/v${RELEASE_VERSION}"` || true if [[ -n "${EXISTING_TAG}" ]]; then echo_warn "Tag v${RELEASE_VERSION} already exists. Exiting." @@ -156,8 +160,8 @@ echo_info "Generating changelog" echo_info "--------------------------------------------" echo_info "" -echo_info "---< git fetch origin main >---" -git fetch origin main +echo_info "---< git fetch origin main --prune --unshallow >---" +git fetch origin main --prune --unshallow echo "" echo_info "Generating changelog from history..." From d22997a0ab65fb798b90a1084985eaab399402fd Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 17:00:42 -0700 Subject: [PATCH 06/10] Tags won't exist on first run, don't fail --- .github/scripts/publish_preflight_check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/publish_preflight_check.sh b/.github/scripts/publish_preflight_check.sh index d7e8a22..d74978c 100755 --- a/.github/scripts/publish_preflight_check.sh +++ b/.github/scripts/publish_preflight_check.sh @@ -135,8 +135,8 @@ echo_info "Checking release tag" echo_info "--------------------------------------------" echo_info "" -echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* >---" -git fetch --depth=1 origin +refs/tags/*:refs/tags/* +echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true >---" +git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true echo "" readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/v${RELEASE_VERSION}"` || true From 83ed421755b7afbfc728f15981b1cd5cebf17de7 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 17:03:09 -0700 Subject: [PATCH 07/10] There was good reason for not using echo_info here. --- .github/scripts/generate_changelog.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/generate_changelog.sh b/.github/scripts/generate_changelog.sh index 71f2b93..598888e 100755 --- a/.github/scripts/generate_changelog.sh +++ b/.github/scripts/generate_changelog.sh @@ -40,14 +40,14 @@ fi LAST_TAG=`git describe --tags $(git rev-list --tags --max-count=1) 2> /dev/null` || true if [[ -z "${LAST_TAG}" ]]; then - echo_info "No tags found. Including all commits up to ${GITHUB_SHA}." + echo "[INFO] No tags found. Including all commits up to ${GITHUB_SHA}." VERSION_RANGE="${GITHUB_SHA}" else - echo_info "Last release tag: ${LAST_TAG}." + echo "[INFO] Last release tag: ${LAST_TAG}." COMMIT_SHA=`git show-ref -s ${LAST_TAG}` - echo_info "Last release commit: ${COMMIT_SHA}." + echo "[INFO] Last release commit: ${COMMIT_SHA}." VERSION_RANGE="${COMMIT_SHA}..${GITHUB_SHA}" - echo_info "Including all commits in the range ${VERSION_RANGE}." + echo "[INFO] Including all commits in the range ${VERSION_RANGE}." fi echo "" From efb47dfb58b191e4626940e258bf8beb17a5d983 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 17:05:46 -0700 Subject: [PATCH 08/10] Fix typo, remove -x flag --- .github/scripts/generate_changelog.sh | 1 - .github/scripts/publish_preflight_check.sh | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/scripts/generate_changelog.sh b/.github/scripts/generate_changelog.sh index 598888e..c4c77f6 100755 --- a/.github/scripts/generate_changelog.sh +++ b/.github/scripts/generate_changelog.sh @@ -16,7 +16,6 @@ set -e set -u -set -x function printChangelog() { local TITLE=$1 diff --git a/.github/scripts/publish_preflight_check.sh b/.github/scripts/publish_preflight_check.sh index d74978c..b3a9c34 100755 --- a/.github/scripts/publish_preflight_check.sh +++ b/.github/scripts/publish_preflight_check.sh @@ -24,7 +24,6 @@ set -e set -u -set -x function echo_info() { local MESSAGE=$1 @@ -175,7 +174,7 @@ FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"` EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) echo "changelog=<<$EOF" >> "$GITHUB_OUTPUT" echo $CHANGELOG >> "$GITHUB_OUTPUT" -echo $EOF >> "$GITHUG_OUTPUT" +echo $EOF >> "$GITHUB_OUTPUT" echo "" From c765f47ba901f6db48a78ca1638e3811a701e8bc Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 17:10:46 -0700 Subject: [PATCH 09/10] Fix multiline output syntax. --- .github/scripts/publish_preflight_check.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/publish_preflight_check.sh b/.github/scripts/publish_preflight_check.sh index b3a9c34..948f2fe 100755 --- a/.github/scripts/publish_preflight_check.sh +++ b/.github/scripts/publish_preflight_check.sh @@ -170,11 +170,11 @@ echo "$CHANGELOG" # Parse and preformat the text to handle multi-line output. # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string -FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"` +FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "[INFO]"` EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) -echo "changelog=<<$EOF" >> "$GITHUB_OUTPUT" -echo $CHANGELOG >> "$GITHUB_OUTPUT" -echo $EOF >> "$GITHUB_OUTPUT" +echo "changelog<<$EOF" >> "$GITHUB_OUTPUT" +echo "$CHANGELOG" >> "$GITHUB_OUTPUT" +echo "$EOF" >> "$GITHUB_OUTPUT" echo "" From 5895bf5cfa268502ee31969aa15edf2f05c3b760 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 26 Apr 2023 17:14:26 -0700 Subject: [PATCH 10/10] Put safeguards back in place. --- .github/workflows/release.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bd6bb02..1d92079 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -72,11 +72,11 @@ jobs: # 2. to the main branch # 3. with the label 'release:publish', and # 4. the title prefix 'chore: Release '. - # if: > - # github.event.pull_request.merged && - # github.ref == 'main' && - # contains(github.event.pull_request.labels.*.name, 'release:publish') && - # startsWith(github.event.pull_request.title, 'chore: Release ') + if: > + github.event.pull_request.merged && + github.ref == 'main' && + contains(github.event.pull_request.labels.*.name, 'release:publish') && + startsWith(github.event.pull_request.title, 'chore: Release ') runs-on: ubuntu-latest @@ -112,4 +112,4 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: user: firebase - password: "abc" \ No newline at end of file + password: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file