From 943d918ad16ca5351caf762b8df3c7623a0e07cb Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Sun, 10 Jul 2022 09:27:57 +0900 Subject: [PATCH 01/13] add summary diff --- .github/workflows/release.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e84190b..830a2cfa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,16 @@ jobs: - name: checkout code uses: actions/checkout@v2 + - name: Cache install release tools + id: cache_tools + uses: actions/cache@v2 + with: + key: cache_tools_0 + path: | + ~/.cargo/bin + - name: Install release tools + if: ${{ steps.cache_tools.outputs.cache-hit==false }} run: | cargo install cargo-edit toml-cli @@ -57,18 +66,25 @@ jobs: git add . git commit -m "update for release v${RELEASE_VERSION}" - - name: cargo publish + - name: Show commit diff run: | - # TODO: de-comment for login - # cargo login "${{ secrets.CRATES_IO_TOKEN }}" - cargo publish -p springql-core --dry-run # TODO: remove `--dry-run` - cargo publish -p springql --dry-run # TODO: remove `--dry-run` + echo '### Release Commit' >> $GITHUB_STEP_SUMMARY + echo '```diff' >> $GITHUB_STEP_SUMMARY + git diff HEAD^ >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY - name: git tag run: | git tag "v${RELEASE_VERSION}" git tag "springql@${RELASE_VERSION}" git tag "springql-core@${RELASE_VERSION}" + + - name: cargo publish + run: | + # TODO: de-comment for login + # cargo login "${{ secrets.CRATES_IO_TOKEN }}" + cargo publish -p springql-core --dry-run # TODO: remove `--dry-run` + cargo publish -p springql --dry-run # TODO: remove `--dry-run` - name: git push run: | From 396e31bb16d33a0165e1fb785ed2d5791da1de1d Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Sun, 10 Jul 2022 09:48:50 +0900 Subject: [PATCH 02/13] keep whitespace --- .github/workflows/scripts/keep-a-changelog.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/keep-a-changelog.bash b/.github/workflows/scripts/keep-a-changelog.bash index 00210fa2..e3b239e0 100644 --- a/.github/workflows/scripts/keep-a-changelog.bash +++ b/.github/workflows/scripts/keep-a-changelog.bash @@ -8,7 +8,7 @@ function bump_changelog() { CURRENT_VERSION=$1 NEW_VERSION=$2 - while read -r line + while IFS='' read -r line do if [ "$line" == "[Unreleased]: https://github.com/SpringQL/SpringQL/compare/${CURRENT_VERSION}...HEAD" ]; then # update line for [Unreleased] From 15dad713c854815a1621f353bc484a0184c65dcf Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Sun, 10 Jul 2022 09:54:48 +0900 Subject: [PATCH 03/13] add v for changelog --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 830a2cfa..99f27790 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,7 @@ jobs: source .github/workflows/scripts/keep-a-changelog.bash # edit CHANGELOG.md cp CHANGELOG.md CHANGELOG.md.org - cat CHANGELOG.md.org | bump_changelog "${CURRENT_VERSION}" "${RELEASE_VERSION}" > CHANGELOG.md + cat CHANGELOG.md.org | bump_changelog "v${CURRENT_VERSION}" "v${RELEASE_VERSION}" > CHANGELOG.md rm CHANGELOG.md.org - name: bump crate versions From 1848fd73a57f9499360e9ac2cfdb0618ed7b0e56 Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Sun, 10 Jul 2022 10:39:12 +0900 Subject: [PATCH 04/13] add wait_published helper function --- .github/workflows/release.yml | 22 ++++++++++++------- .../workflows/scripts/crates.io-script.bash | 19 +++++++++++++++- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99f27790..11c78a18 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,18 +78,24 @@ jobs: git tag "v${RELEASE_VERSION}" git tag "springql@${RELASE_VERSION}" git tag "springql-core@${RELASE_VERSION}" + + - name: git push + run: | + # TODO: de-comment for push + git push origin "v${RELEASE_VERSION}" + git push origin "springql@${RELEASE_VERSION}" + git push origin "springql-core@${RELEASE_VERSION}" + git push origin test_for_release - name: cargo publish run: | + # load helper script + source .github/workflows/scripts/crates.io-script.bash + # TODO: de-comment for login # cargo login "${{ secrets.CRATES_IO_TOKEN }}" + cargo publish -p springql-core --dry-run # TODO: remove `--dry-run` + wait_published "springql-core" "${RELEASE_VERSION}" 2> /dev/null cargo publish -p springql --dry-run # TODO: remove `--dry-run` - - - name: git push - run: | - # TODO: de-comment for push - # git push origin "v${RELEASE_VERSION}" - # git push origin "springql@${RELEASE_VERSION}" - # git push origin "springql-core@${RELEASE_VERSION}" - # git push origin main + wait_published "springql" "${RELEASE_VERSION}" 2> /dev/null diff --git a/.github/workflows/scripts/crates.io-script.bash b/.github/workflows/scripts/crates.io-script.bash index c1495437..ebffcc63 100644 --- a/.github/workflows/scripts/crates.io-script.bash +++ b/.github/workflows/scripts/crates.io-script.bash @@ -10,4 +10,21 @@ function get_crate_latest_version() { curl -L https://crates.io/api/v1/crates/$1/versions | jq -r '.versions[] | select( .yanked == false) | .num' | sort --version-sort | tail -n 1 } -export -f get_crate_latest_version \ No newline at end of file +export -f get_crate_latest_version + +# function: wait_published +# arg#1: crate name +# arg#2: expect version +function wait_published() { + echo "Waiting $1@$2" + CURRENT_VERSION=$(get_crate_latest_version $1) + echo "CURRENT_VERSION=$CURRENT_VERSION" + while [ $CURRENT_VERSION != "$2" ] + do + sleep 5 + CURRENT_VERSION=$(get_crate_latest_version $1) + echo "CURRENT_VERSION=$CURRENT_VERSION" + done +} + +export -f wait_published \ No newline at end of file From 645f6aee16222b21f9d54027a0350714a2871468 Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Mon, 11 Jul 2022 07:44:52 +0900 Subject: [PATCH 05/13] push commits before tag --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11c78a18..469090bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,10 +82,10 @@ jobs: - name: git push run: | # TODO: de-comment for push + git push origin test_for_release git push origin "v${RELEASE_VERSION}" git push origin "springql@${RELEASE_VERSION}" git push origin "springql-core@${RELEASE_VERSION}" - git push origin test_for_release - name: cargo publish run: | From 01ef9a9bfc541dfcceed5aa87f84345f0d625205 Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Mon, 11 Jul 2022 07:55:42 +0900 Subject: [PATCH 06/13] add git-remote origin --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 469090bf..48db5a48 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,6 +82,7 @@ jobs: - name: git push run: | # TODO: de-comment for push + git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} git push origin test_for_release git push origin "v${RELEASE_VERSION}" git push origin "springql@${RELEASE_VERSION}" From 8d993877678e718821d6ef9bc8ff692553b6c4fd Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Mon, 11 Jul 2022 08:07:25 +0900 Subject: [PATCH 07/13] checkout main --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48db5a48..ab8882d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,8 @@ jobs: steps: - name: checkout code uses: actions/checkout@v2 + with: + ref: main - name: Cache install release tools id: cache_tools From 37e5e5d1976d20acd0c54ededd0ac1aa034600d3 Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Mon, 11 Jul 2022 08:27:01 +0900 Subject: [PATCH 08/13] add show initial git status --- .github/workflows/release.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab8882d0..305221da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,14 @@ jobs: with: ref: main + - name: Show initial git status + run: | + echo '### Initial git status' >> $GITHUB_STEP_SUMMARY + echo '```console' >> $GITHUB_STEP_SUMMARY + git status >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + - name: Cache install release tools id: cache_tools uses: actions/cache@v2 From 8ca55f7d601e726beaf1f897d11cad8ab9268854 Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Mon, 11 Jul 2022 08:44:34 +0900 Subject: [PATCH 09/13] show summary verbose --- .github/workflows/release.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 305221da..80d15f16 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,10 +29,9 @@ jobs: run: | echo '### Initial git status' >> $GITHUB_STEP_SUMMARY echo '```console' >> $GITHUB_STEP_SUMMARY - git status >> $GITHUB_STEP_SUMMARY + git status -v >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY - - name: Cache install release tools id: cache_tools uses: actions/cache@v2 @@ -88,15 +87,22 @@ jobs: git tag "v${RELEASE_VERSION}" git tag "springql@${RELASE_VERSION}" git tag "springql-core@${RELASE_VERSION}" - + + - name: Show final git status + run: | + echo '### Final git status' >> $GITHUB_STEP_SUMMARY + echo '```console' >> $GITHUB_STEP_SUMMARY + git status -v >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + - name: git push run: | # TODO: de-comment for push git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} - git push origin test_for_release - git push origin "v${RELEASE_VERSION}" - git push origin "springql@${RELEASE_VERSION}" - git push origin "springql-core@${RELEASE_VERSION}" + git push -v origin test_for_release + git push -v origin "v${RELEASE_VERSION}" + git push -v origin "springql@${RELEASE_VERSION}" + git push -v origin "springql-core@${RELEASE_VERSION}" - name: cargo publish run: | From bcad4e6d676cd50f540d9e10db79a91050cf2d6c Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Tue, 12 Jul 2022 06:13:31 +0900 Subject: [PATCH 10/13] add permission contents write --- .github/workflows/release.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80d15f16..99ac1630 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,8 @@ jobs: env: CURRENT_VERSION: ${{ github.event.inputs.current_version }} RELEASE_VERSION: ${{ github.event.inputs.release_version }} + permissions: + contents: write runs-on: ubuntu-latest steps: @@ -97,9 +99,8 @@ jobs: - name: git push run: | - # TODO: de-comment for push git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} - git push -v origin test_for_release + git push -v origin main git push -v origin "v${RELEASE_VERSION}" git push -v origin "springql@${RELEASE_VERSION}" git push -v origin "springql-core@${RELEASE_VERSION}" @@ -112,7 +113,7 @@ jobs: # TODO: de-comment for login # cargo login "${{ secrets.CRATES_IO_TOKEN }}" - cargo publish -p springql-core --dry-run # TODO: remove `--dry-run` + cargo publish -p springql-core wait_published "springql-core" "${RELEASE_VERSION}" 2> /dev/null - cargo publish -p springql --dry-run # TODO: remove `--dry-run` + cargo publish -p springql wait_published "springql" "${RELEASE_VERSION}" 2> /dev/null From ccc09e12577cd50c595eaab81e9bb42fc112d87c Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Tue, 12 Jul 2022 06:16:09 +0900 Subject: [PATCH 11/13] enable crates.io login --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99ac1630..282ade68 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,8 +110,7 @@ jobs: # load helper script source .github/workflows/scripts/crates.io-script.bash - # TODO: de-comment for login - # cargo login "${{ secrets.CRATES_IO_TOKEN }}" + cargo login "${{ secrets.CRATES_IO_TOKEN }}" cargo publish -p springql-core wait_published "springql-core" "${RELEASE_VERSION}" 2> /dev/null From 17e126298d5e39f65b46a3dff452656a3187e974 Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Tue, 12 Jul 2022 06:28:59 +0900 Subject: [PATCH 12/13] add release date --- .github/workflows/scripts/keep-a-changelog.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scripts/keep-a-changelog.bash b/.github/workflows/scripts/keep-a-changelog.bash index e3b239e0..d60cde8e 100644 --- a/.github/workflows/scripts/keep-a-changelog.bash +++ b/.github/workflows/scripts/keep-a-changelog.bash @@ -19,7 +19,8 @@ function bump_changelog() { if [ "$line" == "## [Unreleased]" ]; then # insert line after ## [Unleleased] echo # output blank line - echo "## [${NEW_VERSION}]" + RELEASE_DATE=$(date '+%Y-%m-%d') + echo "## [${NEW_VERSION}] (${RELEASE_DATE})" fi if [ "$line" == "[Released]: https://github.com/SpringQL/SpringQL/releases" ]; then From 65b04f89fb16c059a558f005e50c83611ce03c42 Mon Sep 17 00:00:00 2001 From: kazuhiko kikuchi Date: Tue, 12 Jul 2022 06:41:37 +0900 Subject: [PATCH 13/13] Update .github/workflows/scripts/keep-a-changelog.bash Co-authored-by: Sho Nakatani --- .github/workflows/scripts/keep-a-changelog.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/keep-a-changelog.bash b/.github/workflows/scripts/keep-a-changelog.bash index d60cde8e..77642acf 100644 --- a/.github/workflows/scripts/keep-a-changelog.bash +++ b/.github/workflows/scripts/keep-a-changelog.bash @@ -20,7 +20,7 @@ function bump_changelog() { # insert line after ## [Unleleased] echo # output blank line RELEASE_DATE=$(date '+%Y-%m-%d') - echo "## [${NEW_VERSION}] (${RELEASE_DATE})" + echo "## [${NEW_VERSION}] - ${RELEASE_DATE}" fi if [ "$line" == "[Released]: https://github.com/SpringQL/SpringQL/releases" ]; then