From 13ad072bee81a4f8befba952f9e4edf23bfdffee Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 13 May 2021 19:29:59 +0300 Subject: [PATCH 01/54] Run go mod tidy --- cmd/genji/go.sum | 1 + engine/badgerengine/go.sum | 1 + 2 files changed, 2 insertions(+) diff --git a/cmd/genji/go.sum b/cmd/genji/go.sum index 2f2a5aaaa..ae0a204f7 100644 --- a/cmd/genji/go.sum +++ b/cmd/genji/go.sum @@ -195,6 +195,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/engine/badgerengine/go.sum b/engine/badgerengine/go.sum index 536442047..351a76a7b 100644 --- a/engine/badgerengine/go.sum +++ b/engine/badgerengine/go.sum @@ -148,6 +148,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= From 2ff5fbe084a8e3bca16efd475c1de24209f1a9a0 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 13 May 2021 19:30:12 +0300 Subject: [PATCH 02/54] Remove explicit versions from replace directives --- cmd/genji/go.mod | 4 ++-- engine/badgerengine/go.mod | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/genji/go.mod b/cmd/genji/go.mod index 7fde89a29..763ad5c7a 100644 --- a/cmd/genji/go.mod +++ b/cmd/genji/go.mod @@ -16,6 +16,6 @@ require ( ) replace ( - github.com/genjidb/genji v0.13.0 => ../../ - github.com/genjidb/genji/engine/badgerengine v0.13.0 => ../../engine/badgerengine + github.com/genjidb/genji => ../../ + github.com/genjidb/genji/engine/badgerengine => ../../engine/badgerengine ) diff --git a/engine/badgerengine/go.mod b/engine/badgerengine/go.mod index 72303eae6..80b79e515 100644 --- a/engine/badgerengine/go.mod +++ b/engine/badgerengine/go.mod @@ -8,4 +8,4 @@ require ( github.com/stretchr/testify v1.7.0 ) -replace github.com/genjidb/genji v0.13.0 => ../../ +replace github.com/genjidb/genji => ../../ From d63e4ecc94f4976174294a91c8cd4140abd02913 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 13 May 2021 22:45:59 +0300 Subject: [PATCH 03/54] Added release workflow --- .github/workflows/release-assets.yaml | 144 +++++++++++++++++++++ .github/workflows/release.yaml | 172 ++++++++++++++++++++++++++ 2 files changed, 316 insertions(+) create mode 100644 .github/workflows/release-assets.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml new file mode 100644 index 000000000..6c4418aac --- /dev/null +++ b/.github/workflows/release-assets.yaml @@ -0,0 +1,144 @@ +name: Release Assets +on: + release: + types: + - published + +jobs: + build: + name: Build + runs-on: ubuntu-latest + # Linux targets should be fixed in https://github.com/dgraph-io/ristretto/commit/6b99600c6cd958495fea33af2bf650c706da4c14 + # Other are failing when compiling github.com/pkg/term@v1.1.0/termios package. + # Plan9 target also fails when compiling bbolt. See https://github.com/etcd-io/bbolt/issues/231 + continue-on-error: ${{ + matrix.os == 'openbsd' || + matrix.os == 'freebsd' || + matrix.os == 'plan9' || + matrix.os == 'linux' && matrix.arch == 'mips64' || + matrix.os == 'linux' && matrix.arch == 'mips64le' || + matrix.os == 'linux' && matrix.arch == 'riscv64' || + matrix.os == 'linux' && matrix.arch == 's390x' || + matrix.os == 'dragonfly' || + matrix.os == 'illumos' || + matrix.os == 'solaris' || + matrix.os == 'aix' || + matrix.allow-failure != '' }} + strategy: + fail-fast: false + matrix: + os: + - linux + - darwin + - windows + - openbsd + - freebsd + - netbsd + - plan9 + arch: + - arm + - 386 + - amd64 + - arm64 + include: + # Extra linux targets + - os: linux + arch: mips + - os: linux + arch: mips64 + - os: linux + arch: mips64le + - os: linux + arch: mipsle + - os: linux + arch: ppc64 + - os: linux + arch: ppc64le + - os: linux + arch: riscv64 + - os: linux + arch: s390x + # Misc targets + - os: dragonfly + arch: amd64 + - os: illumos + arch: amd64 + - os: solaris + arch: amd64 + - os: aix + arch: ppc64 + exclude: + # Needs go1.17. See https://github.com/golang/go/issues/36439#issuecomment-827089403 + - os: windows + arch: arm64 + # Not supported + - os: darwin + arch: 386 + - os: darwin + arch: arm + - os: plan9 + arch: arm64 + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + # Enable reproducible builds. + GOFLAGS: -trimpath + CGO_ENABLED: '0' + GO_EXTLINK_ENABLED: '0' + steps: + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.3 + + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=exe::$(go env GOEXE)" + echo "::set-output name=path::$(go env GOPATH)" + echo "::set-output name=hostos::$(go env GOHOSTOS)" + echo "::set-output name=hostarch::$(go env GOHOSTARCH)" + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + + - name: Set up modules cache + uses: actions/cache@v2.1.5 + with: + path: ${{ steps.go-env.outputs.modcache }} + key: modcache-go-${{ hashFiles('**/go.sum') }} + restore-keys: modcache-go- + + - name: Set up build cache + uses: actions/cache@v2.1.5 + with: + path: ${{ steps.go-env.outputs.cache }} + key: cache-go-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/go.sum') }} + restore-keys: cache-go-${{ matrix.os }}-${{ matrix.arch }} + + - name: Get release version + id: release + run: | + TAG_NAME=${{ github.event.release.tag_name }} + echo "::set-output name=version::${TAG_NAME#cmd/genji/}" + + - name: Get asset name + id: asset + run: | + echo "::set-output name=filename::genji_${{ matrix.os }}_${{ matrix.arch }}${{ steps.go-env.outputs.exe }}" + + - name: Build release asset + run: go install github.com/genjidb/genji/cmd/genji@${{ steps.release.outputs.version }} + + - name: Move asset to GOPATH/bin + if: ${{ steps.go-env.outputs.hostos != matrix.os || steps.go-env.outputs.hostarch != matrix.arch }} + working-directory: ${{ steps.go-env.outputs.path }}/bin/${{ matrix.os }}_${{ matrix.arch }} + run: mv genji${{ steps.go-env.outputs.exe }} .. + + - name: Move asset to workspace + working-directory: ${{ steps.go-env.outputs.path }}/bin + run: mv genji${{ steps.go-env.outputs.exe }} ${{ github.workspace }}/${{ steps.asset.outputs.filename }} + + - name: Upload release asset + run: gh release upload -R ${{ github.repository }} --clobber ${{ github.event.release.tag_name }} ${{ steps.asset.outputs.filename }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..cd7544f4e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,172 @@ +name: Release +on: + push: + branches: + # TODO(tie): allow release/v* for backports? + - release + workflow_dispatch: + inputs: + base: + description: 'Base version' + required: false + default: '' + version: + description: 'New version' + required: false + default: '' + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + env: + GOFLAGS: -trimpath + # Ensure that we have a chance to remove tags for failed release + # before they are added to global sumdb and goproxy cache. + # + # Use version retraction if we can’t safely revert release. + # See https://blog.golang.org/go116-module-changes#TOC_5. + # + GOPRIVATE: github.com/genjidb/genji + outputs: + version: ${{ steps.changelog.outputs.version }} + upload_url: ${{ steps.release.outputs.upload_url }} + if: ${{ github.ref != 'refs/heads/main' }} + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.3 + + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache + uses: actions/cache@v2.1.5 + with: + path: | + ${{ steps.go-env.outputs.cache }} + ${{ steps.go-env.outputs.modcache }} + key: release-go-${{ hashFiles('**/go.sum') }} + restore-keys: release-go- + + - name: Install x/exp/cmd/gorelease + run: go install golang.org/x/exp/cmd/gorelease@v0.0.0-20210513165259-bd7cc9f9ec66 + + - name: Set up Git config + run: | + git config user.name actions-user + git config user.email actions@github.com + + # 1.1. Prepare github.com/genjidb/genji module. + # + # This step will fail if version from input is not a valid semantic version for this release. + # We use the version suggested by gorelease tool if there is no input (workflow on push event). + # The base version is inferred from the new version and defaults to latest release. + # + - name: Generate changelog + run: | + gorelease -base=${{ github.event.inputs.base }} -version=${{ github.event.inputs.version }} | tee changelog.txt + - name: Extract version from changelog + id: changelog + run: | + perl -n -e ' + if (s/^Suggested version: (.*)/::set-output name=version::$1/) { print } + if (s/^(.*) is a valid semantic version for this release.$/::set-output name=version::$1/) { print } + ' changelog.txt + - name: Amend changelog + run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt + + # 1.2. Prepare github.com/genjidb/genji/engine/badgerengine module. + # + # Note that we use steps.changelog.outputs.version instead of github.event.inputs.version + # to ensure that submodule version always corresponds to root module release. + # + - name: Generate changelog for engine/badgerengine + working-directory: engine/badgerengine + run: gorelease -base=${{ github.event.inputs.base }} -version=${{ steps.changelog.outputs.version }} | tee changelog.txt + - name: Amend changelog for engine/badgerengine + working-directory: engine/badgerengine + run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt + + # 2.1. Create tag for github.com/genjidb/genji module. + # + - name: Bump github.com/genjidb/genji + run: | + git tag ${{ steps.changelog.outputs.version }} + git push --tags + + # 2.2. Create tag for github.com/genjidb/genji/engine/badgerengine module. + # + - name: Bump github.com/genjidb/genji/engine/badgerengine + working-directory: engine/badgerengine + run: | + go mod edit -dropreplace=github.com/genjidb/genji + go get github.com/genjidb/genji@${{ steps.changelog.outputs.version }} + go mod tidy + go mod edit -replace=github.com/genjidb/genji=../../ + git add go.mod go.sum + git commit -m 'Bump engine/badgerengine to ${{ steps.changelog.outputs.version }}' + git tag engine/badgerengine/${{ steps.changelog.outputs.version }} + git push && git push --tags + + # 2.3 Create tag for github.com/genjidb/genji/cmd/genji module. + # + - name: Bump github.com/genjidb/genji/cmd/genji + working-directory: cmd/genji + run: | + go mod edit \ + -dropreplace=github.com/genjidb/genji \ + -dropreplace=github.com/genjidb/engine/badgerengine + go get \ + github.com/genjidb/genji@${{ steps.changelog.outputs.version }} \ + github.com/genjidb/genji/engine/badgerengine@${{ steps.changelog.outputs.version }} + go mod tidy + go mod edit \ + -replace=github.com/genjidb/genji=../../ \ + -replace=github.com/genjidb/engine/badgerengine=../../ + git add go.mod go.sum + git commit -m 'Bump cmd/genji to ${{ steps.changelog.outputs.version }}' + git tag cmd/genji/${{ steps.changelog.outputs.version }} + git push && git push --tags + + # 3.1. Create GitHub release draft. + # + - name: Merge changelogs + run: | + echo >>changelog.txt && cat engine/badgerengine/changelog.txt >>changelog.txt + - name: Publish release + id: release + uses: actions/create-release@v1.1.4 + with: + draft: true + tag_name: cmd/genji/${{ steps.changelog.outputs.version }} + release_name: ${{ steps.changelog.outputs.version }} + body_path: changelog.txt + prerelease: ${{ contains(steps.changelog.outputs.version, '-') }} + + # 3.2. Create PR with changes we’ve made. + # + - name: Clean up + run: git clean -xfd + - name: Get branch name + id: github-ref + run: | + echo "::set-output name=short::${GITHUB_REF#refs/*/}" + - name: Create PR + uses: peter-evans/create-pull-request@v3.9.1 + with: + author: GitHub + committer: GitHub + branch: ${{ steps.github-ref.outputs.short }} + delete-branch: true + title: Bump version to ${{ steps.changelog.outputs.version }} + body: | + This PR merges changes made when bumping version to ${{ steps.changelog.outputs.version }}. + + See https://github.com/genjidb/genji/releases/tag/cmd/genji/${{ steps.changelog.outputs.version }} From aead527dc61263fdcce8afb4cc11346e07c53f8c Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 13:55:02 +0300 Subject: [PATCH 04/54] Update .github/workflows/release-assets.yaml --- .github/workflows/release-assets.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index 6c4418aac..ed29eae38 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -113,7 +113,7 @@ jobs: with: path: ${{ steps.go-env.outputs.cache }} key: cache-go-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/go.sum') }} - restore-keys: cache-go-${{ matrix.os }}-${{ matrix.arch }} + restore-keys: cache-go-${{ matrix.os }}-${{ matrix.arch }}- - name: Get release version id: release From b75dd620f6ec41d1f34d1ad8e980ed4608ecc611 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 13:55:10 +0300 Subject: [PATCH 05/54] Update .github/workflows/release.yaml --- .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 cd7544f4e..c9b6cf869 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -129,7 +129,7 @@ jobs: go mod tidy go mod edit \ -replace=github.com/genjidb/genji=../../ \ - -replace=github.com/genjidb/engine/badgerengine=../../ + -replace=github.com/genjidb/engine/badgerengine=../../engine/badgerengine git add go.mod go.sum git commit -m 'Bump cmd/genji to ${{ steps.changelog.outputs.version }}' git tag cmd/genji/${{ steps.changelog.outputs.version }} From 82618cb4736bcd8d03c043c697734cafc4a54ba1 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 15:52:07 +0300 Subject: [PATCH 06/54] Add files generated in release workflow to gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 6755988c2..48220f457 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Files that CI generates in release workflow. +release.txt +changelog.txt + # Binaries for programs and plugins *.exe *.exe~ From c2e7d10d125ef904bfb638caa8c186f971233c43 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 15:55:21 +0300 Subject: [PATCH 07/54] Allow pushing to release branch with explicit version Also fixes go install since we had replace directives in version bump commit. Those are now in a separate commit that moves module back to development mode. And also makes versions a bit more robust by passing them as env vars. This allows us to properly escape them in shell commands. --- .github/workflows/release.yaml | 97 +++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c9b6cf869..ea2a66376 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,8 +2,8 @@ name: Release on: push: branches: - # TODO(tie): allow release/v* for backports? - release + - release-v* workflow_dispatch: inputs: base: @@ -28,9 +28,6 @@ jobs: # See https://blog.golang.org/go116-module-changes#TOC_5. # GOPRIVATE: github.com/genjidb/genji - outputs: - version: ${{ steps.changelog.outputs.version }} - upload_url: ${{ steps.release.outputs.upload_url }} if: ${{ github.ref != 'refs/heads/main' }} steps: - name: Checkout code @@ -46,6 +43,7 @@ jobs: run: | echo "::set-output name=cache::$(go env GOCACHE)" echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache uses: actions/cache@v2.1.5 with: @@ -63,6 +61,31 @@ jobs: git config user.name actions-user git config user.email actions@github.com + # Get current branch name and infer version for this release. + # + # Uses explicit version input if we are running on manual workflow dispatch. + # If we are on release branch with explicit version (e.g. release-v0.13.0) + # then branch != strip_prefix(branch, "release-") and we use branch version. + # Otherwise use empty version and gorelease would suggest a new semantic version. + # + # Note that gorelease will fail if the supplied version is not a valid semantic + # version for this release. + # + - name: Get version + id: version + env: + base: ${{ github.event.inputs.base }} + next: ${{ github.event.inputs.version }} + run: | + branch=${GITHUB_REF#refs/heads/} + branchversion=${branch#release-} + if [ "${next}" = "" -a "${branch}" != "${branchversion}" ]; then + next=${branchversion} + fi + echo "::set-output name=branch::${branch}" + echo "::set-output name=base::${base}" + echo "::set-output name=next::${next}" + # 1.1. Prepare github.com/genjidb/genji module. # # This step will fail if version from input is not a valid semantic version for this release. @@ -70,8 +93,11 @@ jobs: # The base version is inferred from the new version and defaults to latest release. # - name: Generate changelog + env: + base: ${{ steps.version.outputs.base }} + version: ${{ steps.version.outputs.next }} run: | - gorelease -base=${{ github.event.inputs.base }} -version=${{ github.event.inputs.version }} | tee changelog.txt + gorelease -base="${base}" -version="${version}" | tee changelog.txt - name: Extract version from changelog id: changelog run: | @@ -84,12 +110,16 @@ jobs: # 1.2. Prepare github.com/genjidb/genji/engine/badgerengine module. # - # Note that we use steps.changelog.outputs.version instead of github.event.inputs.version + # Note that we use steps.changelog.outputs.version instead of steps.version.outputs.next # to ensure that submodule version always corresponds to root module release. # - name: Generate changelog for engine/badgerengine working-directory: engine/badgerengine - run: gorelease -base=${{ github.event.inputs.base }} -version=${{ steps.changelog.outputs.version }} | tee changelog.txt + env: + base: ${{ github.event.inputs.base }} + version: ${{ steps.changelog.outputs.version }} + run: | + gorelease -base="${base}" -version="${version}" | tee changelog.txt - name: Amend changelog for engine/badgerengine working-directory: engine/badgerengine run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt @@ -97,73 +127,90 @@ jobs: # 2.1. Create tag for github.com/genjidb/genji module. # - name: Bump github.com/genjidb/genji + env: + version: ${{ steps.changelog.outputs.version }} run: | - git tag ${{ steps.changelog.outputs.version }} + git tag "${version}" git push --tags # 2.2. Create tag for github.com/genjidb/genji/engine/badgerengine module. # - name: Bump github.com/genjidb/genji/engine/badgerengine working-directory: engine/badgerengine + env: + version: ${{ steps.changelog.outputs.version }} run: | go mod edit -dropreplace=github.com/genjidb/genji - go get github.com/genjidb/genji@${{ steps.changelog.outputs.version }} + go get github.com/genjidb/genji@"${version}" go mod tidy + git add go.mod go.sum + git commit -m "Bump engine/badgerengine to ${version}" + git tag engine/badgerengine/"${version}" go mod edit -replace=github.com/genjidb/genji=../../ + go mod tidy git add go.mod go.sum - git commit -m 'Bump engine/badgerengine to ${{ steps.changelog.outputs.version }}' - git tag engine/badgerengine/${{ steps.changelog.outputs.version }} + git commit -m 'Back to devel mode in engine/badgerengine' git push && git push --tags # 2.3 Create tag for github.com/genjidb/genji/cmd/genji module. # - name: Bump github.com/genjidb/genji/cmd/genji working-directory: cmd/genji + env: + version: ${{ steps.changelog.outputs.version }} run: | go mod edit \ -dropreplace=github.com/genjidb/genji \ -dropreplace=github.com/genjidb/engine/badgerengine go get \ - github.com/genjidb/genji@${{ steps.changelog.outputs.version }} \ - github.com/genjidb/genji/engine/badgerengine@${{ steps.changelog.outputs.version }} + github.com/genjidb/genji@"${version}" \ + github.com/genjidb/genji/engine/badgerengine@"${version}" go mod tidy + git add go.mod go.sum + git commit -m "Bump cmd/genji to ${version}" + git tag cmd/genji/"${version}" go mod edit \ -replace=github.com/genjidb/genji=../../ \ -replace=github.com/genjidb/engine/badgerengine=../../engine/badgerengine + go mod tidy git add go.mod go.sum - git commit -m 'Bump cmd/genji to ${{ steps.changelog.outputs.version }}' - git tag cmd/genji/${{ steps.changelog.outputs.version }} + git commit -m 'Back to devel mode in cmd/genji' git push && git push --tags # 3.1. Create GitHub release draft. # - - name: Merge changelogs + - name: Concatenate release notes run: | - echo >>changelog.txt && cat engine/badgerengine/changelog.txt >>changelog.txt - - name: Publish release - id: release + if [ -f CHANGELOG.md ]; then + cp CHANGELOG.md release.txt + else + touch release.txt + fi + echo >>release.txt + echo --- >>release.txt + echo >>release.txt + cat changelog.txt >>release.txt + echo >>release.txt + cat engine/badgerengine/changelog.txt >>release.txt + - name: Create release draft uses: actions/create-release@v1.1.4 with: draft: true tag_name: cmd/genji/${{ steps.changelog.outputs.version }} release_name: ${{ steps.changelog.outputs.version }} - body_path: changelog.txt + body_path: release.txt prerelease: ${{ contains(steps.changelog.outputs.version, '-') }} # 3.2. Create PR with changes we’ve made. # - name: Clean up run: git clean -xfd - - name: Get branch name - id: github-ref - run: | - echo "::set-output name=short::${GITHUB_REF#refs/*/}" - name: Create PR uses: peter-evans/create-pull-request@v3.9.1 with: author: GitHub committer: GitHub - branch: ${{ steps.github-ref.outputs.short }} + branch: ${{ steps.version.outputs.branch }} delete-branch: true title: Bump version to ${{ steps.changelog.outputs.version }} body: | From 7530992eac6b613ca82ee57076c2ca88f3d084a9 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 16:53:50 +0300 Subject: [PATCH 08/54] Add android/arm64 to build matrix --- .github/workflows/release-assets.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index ed29eae38..6a968f31c 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -11,6 +11,10 @@ jobs: # Linux targets should be fixed in https://github.com/dgraph-io/ristretto/commit/6b99600c6cd958495fea33af2bf650c706da4c14 # Other are failing when compiling github.com/pkg/term@v1.1.0/termios package. # Plan9 target also fails when compiling bbolt. See https://github.com/etcd-io/bbolt/issues/231 + # + # ios/arm64 requires Cgo and external linker, and ios/amd64, iOS Simulator, is just no worth it. + # Same for all android targets except android/arm64 (which we do build). + # continue-on-error: ${{ matrix.os == 'openbsd' || matrix.os == 'freebsd' || @@ -36,10 +40,10 @@ jobs: - netbsd - plan9 arch: - - arm - - 386 - amd64 - arm64 + - 386 + - arm include: # Extra linux targets - os: linux @@ -59,6 +63,8 @@ jobs: - os: linux arch: s390x # Misc targets + - os: android + arch: arm64 - os: dragonfly arch: amd64 - os: illumos From eb59a82a91c25c1ad2bb8742ecc172b5d323407f Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 18:45:33 +0300 Subject: [PATCH 09/54] Fix badgerengine replace path in release workflow --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ea2a66376..1da85df68 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -161,7 +161,7 @@ jobs: run: | go mod edit \ -dropreplace=github.com/genjidb/genji \ - -dropreplace=github.com/genjidb/engine/badgerengine + -dropreplace=github.com/genjidb/genji/engine/badgerengine go get \ github.com/genjidb/genji@"${version}" \ github.com/genjidb/genji/engine/badgerengine@"${version}" @@ -171,7 +171,7 @@ jobs: git tag cmd/genji/"${version}" go mod edit \ -replace=github.com/genjidb/genji=../../ \ - -replace=github.com/genjidb/engine/badgerengine=../../engine/badgerengine + -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine go mod tidy git add go.mod go.sum git commit -m 'Back to devel mode in cmd/genji' From 5b6e2fb16645c5b48234e96e8ae55f1d8e638c7b Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 19:11:22 +0300 Subject: [PATCH 10/54] Use go mod edit -require instead of go get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Go get, uh, gets confused if go.mod contains non-existent version. That’s the case with current go.mod file. --- .github/workflows/release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1da85df68..8137aeb22 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -141,7 +141,7 @@ jobs: version: ${{ steps.changelog.outputs.version }} run: | go mod edit -dropreplace=github.com/genjidb/genji - go get github.com/genjidb/genji@"${version}" + go mod edit -require=github.com/genjidb/genji@"${version}" go mod tidy git add go.mod go.sum git commit -m "Bump engine/badgerengine to ${version}" @@ -162,9 +162,9 @@ jobs: go mod edit \ -dropreplace=github.com/genjidb/genji \ -dropreplace=github.com/genjidb/genji/engine/badgerengine - go get \ - github.com/genjidb/genji@"${version}" \ - github.com/genjidb/genji/engine/badgerengine@"${version}" + go mod edit \ + -require=github.com/genjidb/genji@"${version}" \ + -require=github.com/genjidb/genji/engine/badgerengine@"${version}" go mod tidy git add go.mod go.sum git commit -m "Bump cmd/genji to ${version}" From 28a539dc3d4ef5fbc9f8b41c5da391888535a45c Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 19:37:44 +0300 Subject: [PATCH 11/54] Use gh for releases instead of deprecated action --- .github/workflows/release.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8137aeb22..12786cd83 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -192,14 +192,16 @@ jobs: cat changelog.txt >>release.txt echo >>release.txt cat engine/badgerengine/changelog.txt >>release.txt + - name: Create release draft - uses: actions/create-release@v1.1.4 - with: - draft: true - tag_name: cmd/genji/${{ steps.changelog.outputs.version }} + run: gh release create -t="${release_name}" -F="${body_path}" -d="${draft}" -p="${prerelease}" "${tag_name}" + env: release_name: ${{ steps.changelog.outputs.version }} body_path: release.txt + draft: true prerelease: ${{ contains(steps.changelog.outputs.version, '-') }} + tag_name: cmd/genji/${{ steps.changelog.outputs.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 3.2. Create PR with changes we’ve made. # From f423b0583447e8f2d7fca8426f0794365bd45e36 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 19:48:34 +0300 Subject: [PATCH 12/54] Set PR base to main branch --- .github/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 12786cd83..b99eaa30c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -212,6 +212,7 @@ jobs: with: author: GitHub committer: GitHub + base: main branch: ${{ steps.version.outputs.branch }} delete-branch: true title: Bump version to ${{ steps.changelog.outputs.version }} From 3983b87f39c0e152c71f80441d499b1ab6f2d7c3 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 20:09:38 +0300 Subject: [PATCH 13/54] Use gh for release workflow pull request --- .github/workflows/release.yaml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b99eaa30c..4872e96fa 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -144,12 +144,12 @@ jobs: go mod edit -require=github.com/genjidb/genji@"${version}" go mod tidy git add go.mod go.sum - git commit -m "Bump engine/badgerengine to ${version}" + git commit --allow-empty -m "Bump engine/badgerengine to ${version}" git tag engine/badgerengine/"${version}" go mod edit -replace=github.com/genjidb/genji=../../ go mod tidy git add go.mod go.sum - git commit -m 'Back to devel mode in engine/badgerengine' + git commit --allow-empty -m 'Back to devel mode in engine/badgerengine' git push && git push --tags # 2.3 Create tag for github.com/genjidb/genji/cmd/genji module. @@ -167,14 +167,14 @@ jobs: -require=github.com/genjidb/genji/engine/badgerengine@"${version}" go mod tidy git add go.mod go.sum - git commit -m "Bump cmd/genji to ${version}" + git commit --allow-empty -m "Bump cmd/genji to ${version}" git tag cmd/genji/"${version}" go mod edit \ -replace=github.com/genjidb/genji=../../ \ -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine go mod tidy git add go.mod go.sum - git commit -m 'Back to devel mode in cmd/genji' + git commit --allow-empty -m 'Back to devel mode in cmd/genji' git push && git push --tags # 3.1. Create GitHub release draft. @@ -205,18 +205,14 @@ jobs: # 3.2. Create PR with changes we’ve made. # - - name: Clean up - run: git clean -xfd - name: Create PR - uses: peter-evans/create-pull-request@v3.9.1 - with: - author: GitHub - committer: GitHub + run: gh pr create -l=release -t="${title}" -b="${body}" -B="${base}" -H="${head}" + env: base: main - branch: ${{ steps.version.outputs.branch }} - delete-branch: true + head: ${{ steps.version.outputs.branch }} title: Bump version to ${{ steps.changelog.outputs.version }} body: | This PR merges changes made when bumping version to ${{ steps.changelog.outputs.version }}. See https://github.com/genjidb/genji/releases/tag/cmd/genji/${{ steps.changelog.outputs.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From c7e1ec5eae882ce48e5ddc1edafee782c2270ace Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 20:13:31 +0300 Subject: [PATCH 14/54] =?UTF-8?q?Don=E2=80=99t=20set=20label=20on=20releas?= =?UTF-8?q?e=20pull=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .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 4872e96fa..8a4bd2655 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -206,7 +206,7 @@ jobs: # 3.2. Create PR with changes we’ve made. # - name: Create PR - run: gh pr create -l=release -t="${title}" -b="${body}" -B="${base}" -H="${head}" + run: gh pr create -t="${title}" -b="${body}" -B="${base}" -H="${head}" env: base: main head: ${{ steps.version.outputs.branch }} From 261115748dd18f97c6a73e64683c2c29a72e47bf Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 20:20:21 +0300 Subject: [PATCH 15/54] =?UTF-8?q?Don=E2=80=99t=20run=20fuzz=20workflow=20f?= =?UTF-8?q?or=20release=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-fuzz.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-fuzz.yaml b/.github/workflows/test-fuzz.yaml index a3046ca6f..e0f7cd112 100644 --- a/.github/workflows/test-fuzz.yaml +++ b/.github/workflows/test-fuzz.yaml @@ -1,6 +1,11 @@ name: Fuzz on: push: + branches-ignore: + - release + - release-v* + tags-ignore: + - '**' pull_request: workflow_dispatch: From b9da34045038ea454aacfbc63516fff544838ebd Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 20:35:47 +0300 Subject: [PATCH 16/54] Create empty commit for root module version bump --- .github/workflows/release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8a4bd2655..2160502ff 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -130,8 +130,9 @@ jobs: env: version: ${{ steps.changelog.outputs.version }} run: | + git commit --allow-empty -m "Bump to ${version}" git tag "${version}" - git push --tags + git push && git push --tags # 2.2. Create tag for github.com/genjidb/genji/engine/badgerengine module. # From e1c7ecbc5010861a1d6723edd00aca2e9cf70ef0 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 21:10:02 +0300 Subject: [PATCH 17/54] Remove PR creation step --- .github/workflows/release.yaml | 79 +++++++++++++++------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2160502ff..20e6d3ea2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,6 +29,8 @@ jobs: # GOPRIVATE: github.com/genjidb/genji if: ${{ github.ref != 'refs/heads/main' }} + outputs: + version: ${{ steps.changelog.outputs.version }} steps: - name: Checkout code uses: actions/checkout@v2.3.4 @@ -124,15 +126,38 @@ jobs: working-directory: engine/badgerengine run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt + # 1.3. Prepare release notes. + # + # We’ll use these later to create draft release. + # + - name: Concatenate release notes + run: | + if [ -f CHANGELOG.md ]; then + cp CHANGELOG.md release.txt + else + touch release.txt + fi + echo >>release.txt + echo --- >>release.txt + echo >>release.txt + cat changelog.txt >>release.txt + echo >>release.txt + cat engine/badgerengine/changelog.txt >>release.txt + # 2.1. Create tag for github.com/genjidb/genji module. # + # For each module we create a version bump commit, tag it and push the tag. + # Then we hard reset to the previous HEAD. That is, we don’t push commits + # to the current branch, but instead create commits on top of the HEAD. + # - name: Bump github.com/genjidb/genji env: version: ${{ steps.changelog.outputs.version }} run: | - git commit --allow-empty -m "Bump to ${version}" + git commit --allow-empty -m "Bump version to ${version}" git tag "${version}" - git push && git push --tags + git push origin "${version}" + git reset --hard HEAD^ # 2.2. Create tag for github.com/genjidb/genji/engine/badgerengine module. # @@ -145,15 +170,12 @@ jobs: go mod edit -require=github.com/genjidb/genji@"${version}" go mod tidy git add go.mod go.sum - git commit --allow-empty -m "Bump engine/badgerengine to ${version}" + git commit --allow-empty -m "Bump version to ${version}" git tag engine/badgerengine/"${version}" - go mod edit -replace=github.com/genjidb/genji=../../ - go mod tidy - git add go.mod go.sum - git commit --allow-empty -m 'Back to devel mode in engine/badgerengine' - git push && git push --tags + git push origin engine/badgerengine/"${version}" + git reset --hard HEAD^ - # 2.3 Create tag for github.com/genjidb/genji/cmd/genji module. + # 2.3. Create tag for github.com/genjidb/genji/cmd/genji module. # - name: Bump github.com/genjidb/genji/cmd/genji working-directory: cmd/genji @@ -168,32 +190,13 @@ jobs: -require=github.com/genjidb/genji/engine/badgerengine@"${version}" go mod tidy git add go.mod go.sum - git commit --allow-empty -m "Bump cmd/genji to ${version}" + git commit --allow-empty -m "Bump version to ${version}" git tag cmd/genji/"${version}" - go mod edit \ - -replace=github.com/genjidb/genji=../../ \ - -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine - go mod tidy - git add go.mod go.sum - git commit --allow-empty -m 'Back to devel mode in cmd/genji' - git push && git push --tags + git push origin cmd/genji/"${version}" + git reset --hard HEAD^ # 3.1. Create GitHub release draft. # - - name: Concatenate release notes - run: | - if [ -f CHANGELOG.md ]; then - cp CHANGELOG.md release.txt - else - touch release.txt - fi - echo >>release.txt - echo --- >>release.txt - echo >>release.txt - cat changelog.txt >>release.txt - echo >>release.txt - cat engine/badgerengine/changelog.txt >>release.txt - - name: Create release draft run: gh release create -t="${release_name}" -F="${body_path}" -d="${draft}" -p="${prerelease}" "${tag_name}" env: @@ -203,17 +206,3 @@ jobs: prerelease: ${{ contains(steps.changelog.outputs.version, '-') }} tag_name: cmd/genji/${{ steps.changelog.outputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # 3.2. Create PR with changes we’ve made. - # - - name: Create PR - run: gh pr create -t="${title}" -b="${body}" -B="${base}" -H="${head}" - env: - base: main - head: ${{ steps.version.outputs.branch }} - title: Bump version to ${{ steps.changelog.outputs.version }} - body: | - This PR merges changes made when bumping version to ${{ steps.changelog.outputs.version }}. - - See https://github.com/genjidb/genji/releases/tag/cmd/genji/${{ steps.changelog.outputs.version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From eb9471603c3f42eee055e5188edfbee3a28c9d3b Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 22:04:12 +0300 Subject: [PATCH 18/54] Tag commits in separate jobs --- .github/workflows/release-assets.yaml | 40 +++--- .github/workflows/release.yaml | 179 +++++++++++++++++++------- 2 files changed, 160 insertions(+), 59 deletions(-) diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index 6a968f31c..e4a73d189 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -4,6 +4,12 @@ on: types: - published +env: + # Enable reproducible builds. + GOFLAGS: -trimpath + CGO_ENABLED: '0' + GO_EXTLINK_ENABLED: '0' + jobs: build: name: Build @@ -87,10 +93,6 @@ jobs: env: GOOS: ${{ matrix.os }} GOARCH: ${{ matrix.arch }} - # Enable reproducible builds. - GOFLAGS: -trimpath - CGO_ENABLED: '0' - GO_EXTLINK_ENABLED: '0' steps: - name: Install Go uses: actions/setup-go@v2.1.3 @@ -121,30 +123,36 @@ jobs: key: cache-go-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/go.sum') }} restore-keys: cache-go-${{ matrix.os }}-${{ matrix.arch }}- - - name: Get release version - id: release - run: | - TAG_NAME=${{ github.event.release.tag_name }} - echo "::set-output name=version::${TAG_NAME#cmd/genji/}" - - name: Get asset name id: asset - run: | - echo "::set-output name=filename::genji_${{ matrix.os }}_${{ matrix.arch }}${{ steps.go-env.outputs.exe }}" + run: echo "::set-output name=filename::genji_${GOOS}_${GOARCH}${GOEXE}" + env: + GOEXE: ${{ steps.go-env.outputs.exe }} - name: Build release asset - run: go install github.com/genjidb/genji/cmd/genji@${{ steps.release.outputs.version }} + env: + version: ${{ github.event.release.tag_name }} + run: go install github.com/genjidb/genji/cmd/genji@"${version}" - name: Move asset to GOPATH/bin if: ${{ steps.go-env.outputs.hostos != matrix.os || steps.go-env.outputs.hostarch != matrix.arch }} working-directory: ${{ steps.go-env.outputs.path }}/bin/${{ matrix.os }}_${{ matrix.arch }} - run: mv genji${{ steps.go-env.outputs.exe }} .. + run: mv genji"${GOEXE}" .. + env: + GOEXE: ${{ steps.go-env.outputs.exe }} - name: Move asset to workspace working-directory: ${{ steps.go-env.outputs.path }}/bin - run: mv genji${{ steps.go-env.outputs.exe }} ${{ github.workspace }}/${{ steps.asset.outputs.filename }} + run: mv genji"${GOEXE}" "${workspace}"/"${filename}" + env: + GOEXE: ${{ steps.go-env.outputs.exe }} + workspace: ${{ github.workspace }} + filename: ${{ steps.asset.outputs.filename }} - name: Upload release asset - run: gh release upload -R ${{ github.repository }} --clobber ${{ github.event.release.tag_name }} ${{ steps.asset.outputs.filename }} + run: gh release upload -R="${repo}" "${tag_name}" "${filename}" env: + repo: ${{ github.repository }} + tag_name: ${{ github.event.release.tag_name }} + filename: ${{ steps.asset.outputs.filename }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 20e6d3ea2..6e754a4f9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,20 +15,22 @@ on: required: false default: '' +env: + # Ensure that we have a chance to remove tags for failed release + # before they are added to global sumdb and goproxy cache. + # + # Use version retraction if we can’t safely revert release. + # See https://blog.golang.org/go116-module-changes#TOC_5. + GOPRIVATE: github.com/genjidb/genji + # Enable reproducible builds. + GOFLAGS: -trimpath + CGO_ENABLED: '0' + GO_EXTLINK_ENABLED: '0' + jobs: - publish: - name: Publish + prepare: + name: Prepare runs-on: ubuntu-latest - env: - GOFLAGS: -trimpath - # Ensure that we have a chance to remove tags for failed release - # before they are added to global sumdb and goproxy cache. - # - # Use version retraction if we can’t safely revert release. - # See https://blog.golang.org/go116-module-changes#TOC_5. - # - GOPRIVATE: github.com/genjidb/genji - if: ${{ github.ref != 'refs/heads/main' }} outputs: version: ${{ steps.changelog.outputs.version }} steps: @@ -52,8 +54,8 @@ jobs: path: | ${{ steps.go-env.outputs.cache }} ${{ steps.go-env.outputs.modcache }} - key: release-go-${{ hashFiles('**/go.sum') }} - restore-keys: release-go- + key: prepare-go-${{ hashFiles('**/go.sum') }} + restore-keys: prepare-go- - name: Install x/exp/cmd/gorelease run: go install golang.org/x/exp/cmd/gorelease@v0.0.0-20210513165259-bd7cc9f9ec66 @@ -84,11 +86,10 @@ jobs: if [ "${next}" = "" -a "${branch}" != "${branchversion}" ]; then next=${branchversion} fi - echo "::set-output name=branch::${branch}" echo "::set-output name=base::${base}" echo "::set-output name=next::${next}" - # 1.1. Prepare github.com/genjidb/genji module. + # Check github.com/genjidb/genji module. # # This step will fail if version from input is not a valid semantic version for this release. # We use the version suggested by gorelease tool if there is no input (workflow on push event). @@ -110,7 +111,7 @@ jobs: - name: Amend changelog run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt - # 1.2. Prepare github.com/genjidb/genji/engine/badgerengine module. + # Check github.com/genjidb/genji/engine/badgerengine module. # # Note that we use steps.changelog.outputs.version instead of steps.version.outputs.next # to ensure that submodule version always corresponds to root module release. @@ -126,9 +127,7 @@ jobs: working-directory: engine/badgerengine run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt - # 1.3. Prepare release notes. - # - # We’ll use these later to create draft release. + # Prepare release notes. We’ll use these later to create draft release. # - name: Concatenate release notes run: | @@ -143,28 +142,84 @@ jobs: cat changelog.txt >>release.txt echo >>release.txt cat engine/badgerengine/changelog.txt >>release.txt + - uses: actions/upload-artifact@v2.2.3 + with: + name: release.txt + path: release.txt + if-no-files-found: error + retention-days: 1 - # 2.1. Create tag for github.com/genjidb/genji module. - # - # For each module we create a version bump commit, tag it and push the tag. - # Then we hard reset to the previous HEAD. That is, we don’t push commits - # to the current branch, but instead create commits on top of the HEAD. - # + tag1: + name: Tag github.com/genjidb/genji + runs-on: ubuntu-latest + needs: + - prepare + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.3 + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache + uses: actions/cache@v2.1.5 + with: + path: | + ${{ steps.go-env.outputs.cache }} + ${{ steps.go-env.outputs.modcache }} + key: tag1-go-${{ hashFiles('**/go.sum') }} + restore-keys: tag1-go- + - name: Set up Git config + run: | + git config user.name actions-user + git config user.email actions@github.com - name: Bump github.com/genjidb/genji env: - version: ${{ steps.changelog.outputs.version }} + version: ${{ needs.prepare.outputs.version }} run: | git commit --allow-empty -m "Bump version to ${version}" git tag "${version}" git push origin "${version}" - git reset --hard HEAD^ - # 2.2. Create tag for github.com/genjidb/genji/engine/badgerengine module. - # + tag2: + name: Tag github.com/genjidb/genji/engine/badgerengine + runs-on: ubuntu-latest + needs: + - prepare + - tag1 + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.3 + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache + uses: actions/cache@v2.1.5 + with: + path: | + ${{ steps.go-env.outputs.cache }} + ${{ steps.go-env.outputs.modcache }} + key: tag2-go-${{ hashFiles('**/go.sum') }} + restore-keys: tag2-go- + - name: Set up Git config + run: | + git config user.name actions-user + git config user.email actions@github.com - name: Bump github.com/genjidb/genji/engine/badgerengine working-directory: engine/badgerengine env: - version: ${{ steps.changelog.outputs.version }} + version: ${{ needs.prepare.outputs.version }} run: | go mod edit -dropreplace=github.com/genjidb/genji go mod edit -require=github.com/genjidb/genji@"${version}" @@ -173,14 +228,42 @@ jobs: git commit --allow-empty -m "Bump version to ${version}" git tag engine/badgerengine/"${version}" git push origin engine/badgerengine/"${version}" - git reset --hard HEAD^ - # 2.3. Create tag for github.com/genjidb/genji/cmd/genji module. - # + tag3: + name: Tag github.com/genjidb/genji/cmd/genji + runs-on: ubuntu-latest + needs: + - prepare + - tag1 + - tag2 + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.3 + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache + uses: actions/cache@v2.1.5 + with: + path: | + ${{ steps.go-env.outputs.cache }} + ${{ steps.go-env.outputs.modcache }} + key: tag3-go-${{ hashFiles('**/go.sum') }} + restore-keys: tag3-go- + - name: Set up Git config + run: | + git config user.name actions-user + git config user.email actions@github.com - name: Bump github.com/genjidb/genji/cmd/genji working-directory: cmd/genji env: - version: ${{ steps.changelog.outputs.version }} + version: ${{ needs.prepare.outputs.version }} run: | go mod edit \ -dropreplace=github.com/genjidb/genji \ @@ -193,16 +276,26 @@ jobs: git commit --allow-empty -m "Bump version to ${version}" git tag cmd/genji/"${version}" git push origin cmd/genji/"${version}" - git reset --hard HEAD^ - # 3.1. Create GitHub release draft. - # - - name: Create release draft - run: gh release create -t="${release_name}" -F="${body_path}" -d="${draft}" -p="${prerelease}" "${tag_name}" + draft: + name: Draft + runs-on: ubuntu-latest + needs: + - prepare + - tag1 + - tag2 + - tag3 + steps: + - uses: actions/download-artifact@v2.0.9 + with: + name: release.txt + - name: Draft release + run: gh release create -R="${repo}" -t="${release_name}" -F="${body_path}" -d="${draft}" -p="${prerelease}" "${tag_name}" env: - release_name: ${{ steps.changelog.outputs.version }} + repo: ${{ github.repository }} + release_name: ${{ needs.prepare.outputs.version }} body_path: release.txt draft: true - prerelease: ${{ contains(steps.changelog.outputs.version, '-') }} - tag_name: cmd/genji/${{ steps.changelog.outputs.version }} + prerelease: ${{ contains(needs.prepare.outputs.version, '-') }} + tag_name: ${{ needs.prepare.outputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e003170f33d63efacd3c99538b1d9aa2e6b7b9cd Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 22:07:44 +0300 Subject: [PATCH 19/54] Always use v0.0.0-devel for replaced modules --- cmd/genji/go.mod | 4 ++-- engine/badgerengine/go.mod | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/genji/go.mod b/cmd/genji/go.mod index 763ad5c7a..c2bb23841 100644 --- a/cmd/genji/go.mod +++ b/cmd/genji/go.mod @@ -6,8 +6,8 @@ require ( github.com/agnivade/levenshtein v1.1.0 github.com/c-bata/go-prompt v0.2.5 github.com/dgraph-io/badger/v3 v3.2011.1 - github.com/genjidb/genji v0.13.0 - github.com/genjidb/genji/engine/badgerengine v0.13.0 + github.com/genjidb/genji v0.0.0-devel + github.com/genjidb/genji/engine/badgerengine v0.0.0-devel github.com/stretchr/testify v1.7.0 github.com/urfave/cli/v2 v2.3.0 go.etcd.io/bbolt v1.3.5 diff --git a/engine/badgerengine/go.mod b/engine/badgerengine/go.mod index 80b79e515..b631e2dae 100644 --- a/engine/badgerengine/go.mod +++ b/engine/badgerengine/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/dgraph-io/badger/v3 v3.2011.1 - github.com/genjidb/genji v0.13.0 + github.com/genjidb/genji v0.0.0-devel github.com/stretchr/testify v1.7.0 ) From 0135b0780b96644695711dd7019a5ff52840e44b Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 22:24:38 +0300 Subject: [PATCH 20/54] Make job names shorter --- .github/workflows/release.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6e754a4f9..ff649c56b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -150,7 +150,7 @@ jobs: retention-days: 1 tag1: - name: Tag github.com/genjidb/genji + name: Tag genji runs-on: ubuntu-latest needs: - prepare @@ -187,7 +187,7 @@ jobs: git push origin "${version}" tag2: - name: Tag github.com/genjidb/genji/engine/badgerengine + name: Tag genji/engine/badgerengine runs-on: ubuntu-latest needs: - prepare @@ -230,7 +230,7 @@ jobs: git push origin engine/badgerengine/"${version}" tag3: - name: Tag github.com/genjidb/genji/cmd/genji + name: Tag genji/cmd/genji runs-on: ubuntu-latest needs: - prepare @@ -278,7 +278,7 @@ jobs: git push origin cmd/genji/"${version}" draft: - name: Draft + name: Create Draft runs-on: ubuntu-latest needs: - prepare @@ -290,12 +290,11 @@ jobs: with: name: release.txt - name: Draft release - run: gh release create -R="${repo}" -t="${release_name}" -F="${body_path}" -d="${draft}" -p="${prerelease}" "${tag_name}" + run: gh release create --draft -R="${repo}" -t="${release_name}" -F="${body_path}" -p="${prerelease}" "${tag_name}" env: repo: ${{ github.repository }} release_name: ${{ needs.prepare.outputs.version }} body_path: release.txt - draft: true prerelease: ${{ contains(needs.prepare.outputs.version, '-') }} tag_name: ${{ needs.prepare.outputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f51b8620a0af0a4a1268f02e07902efe3dbbff88 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 22:51:41 +0300 Subject: [PATCH 21/54] Remove no-op step from prepare job --- .github/workflows/release.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ff649c56b..428f11ab0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -60,11 +60,6 @@ jobs: - name: Install x/exp/cmd/gorelease run: go install golang.org/x/exp/cmd/gorelease@v0.0.0-20210513165259-bd7cc9f9ec66 - - name: Set up Git config - run: | - git config user.name actions-user - git config user.email actions@github.com - # Get current branch name and infer version for this release. # # Uses explicit version input if we are running on manual workflow dispatch. From 3d1dcd11bdd732a51e0b1f1bbfa19804d9594200 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 14 May 2021 22:52:26 +0300 Subject: [PATCH 22/54] Add dependabot config for actions --- .github/dependabot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..aea3ce380 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + day: sunday + time: "10:00" + timezone: Etc/UTC From 65c7311acca3adfcb0c41e8622fc033b77bbaf46 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 02:00:10 +0300 Subject: [PATCH 23/54] Rollback release on failure --- .github/workflows/release.yaml | 57 ++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 428f11ab0..99ce74d59 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,9 +18,6 @@ on: env: # Ensure that we have a chance to remove tags for failed release # before they are added to global sumdb and goproxy cache. - # - # Use version retraction if we can’t safely revert release. - # See https://blog.golang.org/go116-module-changes#TOC_5. GOPRIVATE: github.com/genjidb/genji # Enable reproducible builds. GOFLAGS: -trimpath @@ -28,8 +25,8 @@ env: GO_EXTLINK_ENABLED: '0' jobs: - prepare: - name: Prepare + prepare1: + name: Prepare genji runs-on: ubuntu-latest outputs: version: ${{ steps.changelog.outputs.version }} @@ -54,8 +51,8 @@ jobs: path: | ${{ steps.go-env.outputs.cache }} ${{ steps.go-env.outputs.modcache }} - key: prepare-go-${{ hashFiles('**/go.sum') }} - restore-keys: prepare-go- + key: prepare1-go-${{ hashFiles('**/go.sum') }} + restore-keys: prepare1-go- - name: Install x/exp/cmd/gorelease run: go install golang.org/x/exp/cmd/gorelease@v0.0.0-20210513165259-bd7cc9f9ec66 @@ -137,7 +134,8 @@ jobs: cat changelog.txt >>release.txt echo >>release.txt cat engine/badgerengine/changelog.txt >>release.txt - - uses: actions/upload-artifact@v2.2.3 + - name: Upload artifact + uses: actions/upload-artifact@v2.2.3 with: name: release.txt path: release.txt @@ -148,7 +146,7 @@ jobs: name: Tag genji runs-on: ubuntu-latest needs: - - prepare + - prepare1 steps: - name: Checkout code uses: actions/checkout@v2.3.4 @@ -175,7 +173,7 @@ jobs: git config user.email actions@github.com - name: Bump github.com/genjidb/genji env: - version: ${{ needs.prepare.outputs.version }} + version: ${{ needs.prepare1.outputs.version }} run: | git commit --allow-empty -m "Bump version to ${version}" git tag "${version}" @@ -185,7 +183,7 @@ jobs: name: Tag genji/engine/badgerengine runs-on: ubuntu-latest needs: - - prepare + - prepare1 - tag1 steps: - name: Checkout code @@ -214,7 +212,7 @@ jobs: - name: Bump github.com/genjidb/genji/engine/badgerengine working-directory: engine/badgerengine env: - version: ${{ needs.prepare.outputs.version }} + version: ${{ needs.prepare1.outputs.version }} run: | go mod edit -dropreplace=github.com/genjidb/genji go mod edit -require=github.com/genjidb/genji@"${version}" @@ -228,7 +226,7 @@ jobs: name: Tag genji/cmd/genji runs-on: ubuntu-latest needs: - - prepare + - prepare1 - tag1 - tag2 steps: @@ -258,7 +256,7 @@ jobs: - name: Bump github.com/genjidb/genji/cmd/genji working-directory: cmd/genji env: - version: ${{ needs.prepare.outputs.version }} + version: ${{ needs.prepare1.outputs.version }} run: | go mod edit \ -dropreplace=github.com/genjidb/genji \ @@ -276,20 +274,41 @@ jobs: name: Create Draft runs-on: ubuntu-latest needs: - - prepare + - prepare1 - tag1 - tag2 - tag3 steps: - - uses: actions/download-artifact@v2.0.9 + - name: Download artifact + uses: actions/download-artifact@v2.0.9 with: name: release.txt - name: Draft release run: gh release create --draft -R="${repo}" -t="${release_name}" -F="${body_path}" -p="${prerelease}" "${tag_name}" env: repo: ${{ github.repository }} - release_name: ${{ needs.prepare.outputs.version }} + release_name: ${{ needs.prepare1.outputs.version }} body_path: release.txt - prerelease: ${{ contains(needs.prepare.outputs.version, '-') }} - tag_name: ${{ needs.prepare.outputs.version }} + prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} + tag_name: ${{ needs.prepare1.outputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + rollback: + name: Rollback + needs: + - prepare1 + - tag1 + - tag2 + - tag3 + if: ${{ !success() && needs.prepare1.outputs.version != '' }} + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Remove tags + env: + version: ${{ needs.prepare1.outputs.version }} + run: | + git push origin \ + :refs/tags/cmd/genji/"${version}" \ + :refs/tags/engine/badgerengine/"${version}" \ + :refs/tags/"${version}" From fb0cb91212c3724da907a225a22150e8f4a41bd3 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 02:05:14 +0300 Subject: [PATCH 24/54] Change some step names --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 99ce74d59..348f90cde 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -283,7 +283,7 @@ jobs: uses: actions/download-artifact@v2.0.9 with: name: release.txt - - name: Draft release + - name: Create release run: gh release create --draft -R="${repo}" -t="${release_name}" -F="${body_path}" -p="${prerelease}" "${tag_name}" env: repo: ${{ github.repository }} @@ -304,7 +304,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2.3.4 - - name: Remove tags + - name: Delete tags env: version: ${{ needs.prepare1.outputs.version }} run: | From 77f06ec82e693cc0655dc73327df4a54c43602b9 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 03:04:30 +0300 Subject: [PATCH 25/54] Generate changelog for badgerengine after tagging root module --- .github/workflows/release.yaml | 118 ++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 45 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 348f90cde..c8bc2f37d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -33,18 +33,15 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2.3.4 - - name: Install Go uses: actions/setup-go@v2.1.3 with: go-version: 1.16.3 - - name: Get Go environment id: go-env run: | echo "::set-output name=cache::$(go env GOCACHE)" echo "::set-output name=modcache::$(go env GOMODCACHE)" - - name: Set up cache uses: actions/cache@v2.1.5 with: @@ -53,7 +50,6 @@ jobs: ${{ steps.go-env.outputs.modcache }} key: prepare1-go-${{ hashFiles('**/go.sum') }} restore-keys: prepare1-go- - - name: Install x/exp/cmd/gorelease run: go install golang.org/x/exp/cmd/gorelease@v0.0.0-20210513165259-bd7cc9f9ec66 @@ -102,25 +98,6 @@ jobs: ' changelog.txt - name: Amend changelog run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt - - # Check github.com/genjidb/genji/engine/badgerengine module. - # - # Note that we use steps.changelog.outputs.version instead of steps.version.outputs.next - # to ensure that submodule version always corresponds to root module release. - # - - name: Generate changelog for engine/badgerengine - working-directory: engine/badgerengine - env: - base: ${{ github.event.inputs.base }} - version: ${{ steps.changelog.outputs.version }} - run: | - gorelease -base="${base}" -version="${version}" | tee changelog.txt - - name: Amend changelog for engine/badgerengine - working-directory: engine/badgerengine - run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt - - # Prepare release notes. We’ll use these later to create draft release. - # - name: Concatenate release notes run: | if [ -f CHANGELOG.md ]; then @@ -132,8 +109,6 @@ jobs: echo --- >>release.txt echo >>release.txt cat changelog.txt >>release.txt - echo >>release.txt - cat engine/badgerengine/changelog.txt >>release.txt - name: Upload artifact uses: actions/upload-artifact@v2.2.3 with: @@ -179,11 +154,84 @@ jobs: git tag "${version}" git push origin "${version}" + prepare2: + name: Prepare genji/engine/badgerengine + runs-on: ubuntu-latest + needs: + - prepare1 + - tag1 + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.3 + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache + uses: actions/cache@v2.1.5 + with: + path: | + ${{ steps.go-env.outputs.cache }} + ${{ steps.go-env.outputs.modcache }} + key: prepare2-go-${{ hashFiles('**/go.sum') }} + restore-keys: prepare2-go- + - name: Install x/exp/cmd/gorelease + run: go install golang.org/x/exp/cmd/gorelease@v0.0.0-20210513165259-bd7cc9f9ec66 + - name: Drop replace directives + working-directory: engine/badgerengine + env: + version: ${{ needs.prepare1.outputs.version }} + run: | + go mod edit -dropreplace=github.com/genjidb/genji + go mod edit -require=github.com/genjidb/genji@"${version}" + go mod tidy + - name: Generate changelog + working-directory: engine/badgerengine + env: + base: ${{ github.event.inputs.base }} + version: ${{ needs.prepare1.outputs.version }} + run: | + gorelease -base="${base}" -version="${version}" | tee changelog.txt + - name: Amend changelog + working-directory: engine/badgerengine + run: perl -0pi -e 's/(\n.+)+\n+$//' changelog.txt + - name: Download artifact + uses: actions/download-artifact@v2.0.9 + with: + name: release.txt + - name: Concatenate release notes + run: | + echo >>release.txt + echo --- >>release.txt + echo >>release.txt + cat changelog.txt >>release.txt + - name: Upload artifact + uses: actions/upload-artifact@v2.2.3 + with: + name: release.txt + path: release.txt + if-no-files-found: error + retention-days: 1 + + # Remove tag1 if we can’t check semver for badgerengine. + - name: Rollback + if: ${{ failure() }} + env: + version: ${{ needs.prepare1.outputs.version }} + run: | + git push origin :refs/tags/"${version}" + tag2: name: Tag genji/engine/badgerengine runs-on: ubuntu-latest needs: - prepare1 + - prepare2 - tag1 steps: - name: Checkout code @@ -292,23 +340,3 @@ jobs: prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} tag_name: ${{ needs.prepare1.outputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - rollback: - name: Rollback - needs: - - prepare1 - - tag1 - - tag2 - - tag3 - if: ${{ !success() && needs.prepare1.outputs.version != '' }} - steps: - - name: Checkout code - uses: actions/checkout@v2.3.4 - - name: Delete tags - env: - version: ${{ needs.prepare1.outputs.version }} - run: | - git push origin \ - :refs/tags/cmd/genji/"${version}" \ - :refs/tags/engine/badgerengine/"${version}" \ - :refs/tags/"${version}" From f7c07c207e3723531078a52fe611cdf673913015 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 03:13:00 +0300 Subject: [PATCH 26/54] Fix changelog path for badgerengine --- .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 c8bc2f37d..076397200 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -209,7 +209,7 @@ jobs: echo >>release.txt echo --- >>release.txt echo >>release.txt - cat changelog.txt >>release.txt + cat engine/badgerengine/changelog.txt >>release.txt - name: Upload artifact uses: actions/upload-artifact@v2.2.3 with: From 982d73f271edee5d4f9d4760030dae22dbafef06 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 03:17:07 +0300 Subject: [PATCH 27/54] Use go1.16.4 in actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub updated Go version in tools cache. Use that so we don’t have to wait for download. --- .github/workflows/release-assets.yaml | 2 +- .github/workflows/release.yaml | 10 +++++----- .github/workflows/test-fuzz.yaml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index e4a73d189..645d4b82e 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -97,7 +97,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16.3 + go-version: 1.16.4 - name: Get Go environment id: go-env diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 076397200..a599ec690 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,7 +36,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16.3 + go-version: 1.16.4 - name: Get Go environment id: go-env run: | @@ -128,7 +128,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16.3 + go-version: 1.16.4 - name: Get Go environment id: go-env run: | @@ -166,7 +166,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16.3 + go-version: 1.16.4 - name: Get Go environment id: go-env run: | @@ -239,7 +239,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16.3 + go-version: 1.16.4 - name: Get Go environment id: go-env run: | @@ -283,7 +283,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16.3 + go-version: 1.16.4 - name: Get Go environment id: go-env run: | diff --git a/.github/workflows/test-fuzz.yaml b/.github/workflows/test-fuzz.yaml index e0f7cd112..aa767a528 100644 --- a/.github/workflows/test-fuzz.yaml +++ b/.github/workflows/test-fuzz.yaml @@ -22,7 +22,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16.3 + go-version: 1.16.4 - name: Get Go environment id: go-env From dfa8155661e826ef2eff74f056b1a4b9ec1822a9 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 03:19:37 +0300 Subject: [PATCH 28/54] Use even shorter job names in release workflow --- .github/workflows/release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a599ec690..af18f88f6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -155,7 +155,7 @@ jobs: git push origin "${version}" prepare2: - name: Prepare genji/engine/badgerengine + name: Prepare badgerengine runs-on: ubuntu-latest needs: - prepare1 @@ -227,7 +227,7 @@ jobs: git push origin :refs/tags/"${version}" tag2: - name: Tag genji/engine/badgerengine + name: Tag badgerengine runs-on: ubuntu-latest needs: - prepare1 @@ -271,7 +271,7 @@ jobs: git push origin engine/badgerengine/"${version}" tag3: - name: Tag genji/cmd/genji + name: Tag cmd/genji runs-on: ubuntu-latest needs: - prepare1 From bcd383936a9e0509f5dac09c3e37ad6eb6cffdc0 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 03:22:51 +0300 Subject: [PATCH 29/54] Use shorter step names --- .github/workflows/release.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index af18f88f6..8b2c0fdf6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -109,6 +109,7 @@ jobs: echo --- >>release.txt echo >>release.txt cat changelog.txt >>release.txt + echo >>release.txt - name: Upload artifact uses: actions/upload-artifact@v2.2.3 with: @@ -146,7 +147,7 @@ jobs: run: | git config user.name actions-user git config user.email actions@github.com - - name: Bump github.com/genjidb/genji + - name: Bump version env: version: ${{ needs.prepare1.outputs.version }} run: | @@ -257,7 +258,7 @@ jobs: run: | git config user.name actions-user git config user.email actions@github.com - - name: Bump github.com/genjidb/genji/engine/badgerengine + - name: Bump version working-directory: engine/badgerengine env: version: ${{ needs.prepare1.outputs.version }} @@ -301,7 +302,7 @@ jobs: run: | git config user.name actions-user git config user.email actions@github.com - - name: Bump github.com/genjidb/genji/cmd/genji + - name: Bump version working-directory: cmd/genji env: version: ${{ needs.prepare1.outputs.version }} From 9613e529677ac38bddb376d4deb88377829d2937 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 04:03:23 +0300 Subject: [PATCH 30/54] Rollback from separate job --- .github/workflows/release.yaml | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8b2c0fdf6..9edf205a8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -219,14 +219,6 @@ jobs: if-no-files-found: error retention-days: 1 - # Remove tag1 if we can’t check semver for badgerengine. - - name: Rollback - if: ${{ failure() }} - env: - version: ${{ needs.prepare1.outputs.version }} - run: | - git push origin :refs/tags/"${version}" - tag2: name: Tag badgerengine runs-on: ubuntu-latest @@ -341,3 +333,28 @@ jobs: prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} tag_name: ${{ needs.prepare1.outputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + rollback: + name: Rollback + runs-on: ubuntu-latest + needs: + - prepare1 + - tag1 + - tag2 + - tag3 + - draft + env: + version: ${{ needs.prepare1.outputs.version }} + if: ${{ always() && !success() }} + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Untag genji + if: ${{ needs.tag1.result == 'success' }} + run: git push origin :refs/tags/"${version}" + - name: Untag badgerengine + if: ${{ needs.tag2.result == 'success' }} + run: git push origin :refs/tags/engine/badgerengine/"${version}" + - name: Untag cmd/genji + if: ${{ needs.tag3.result == 'success' }} + run: git push origin :refs/tags/cmd/genji/"${version}" From c70a558dbe77eee1adca70f409a6c7a6391d3502 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 04:18:07 +0300 Subject: [PATCH 31/54] Also rollback draft release on failure --- .github/workflows/release.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9edf205a8..556fdeb8f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -319,20 +319,24 @@ jobs: - tag1 - tag2 - tag3 + outputs: + id: ${{ steps.release.outputs.id }} steps: - name: Download artifact uses: actions/download-artifact@v2.0.9 with: name: release.txt - name: Create release - run: gh release create --draft -R="${repo}" -t="${release_name}" -F="${body_path}" -p="${prerelease}" "${tag_name}" + id: release + uses: actions/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} env: - repo: ${{ github.repository }} + tag_name: ${{ needs.prepare1.outputs.version }} release_name: ${{ needs.prepare1.outputs.version }} body_path: release.txt prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} - tag_name: ${{ needs.prepare1.outputs.version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + draft: true rollback: name: Rollback @@ -358,3 +362,8 @@ jobs: - name: Untag cmd/genji if: ${{ needs.tag3.result == 'success' }} run: git push origin :refs/tags/cmd/genji/"${version}" + - name: Discard draft + if: ${{ needs.draft.result == 'success' }} + uses: author/action-rollback@v1.0.3 + with: + release_id: ${{ needs.draft.outputs.id }} From 6d414167ae4fd150cda70a6b6988fabdf5f170cb Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 04:26:55 +0300 Subject: [PATCH 32/54] Use author/action-rollback for untagging --- .github/workflows/release.yaml | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 556fdeb8f..837268838 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -348,22 +348,29 @@ jobs: - tag3 - draft env: - version: ${{ needs.prepare1.outputs.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ always() && !success() }} steps: - - name: Checkout code - uses: actions/checkout@v2.3.4 - - name: Untag genji - if: ${{ needs.tag1.result == 'success' }} - run: git push origin :refs/tags/"${version}" - - name: Untag badgerengine - if: ${{ needs.tag2.result == 'success' }} - run: git push origin :refs/tags/engine/badgerengine/"${version}" - - name: Untag cmd/genji - if: ${{ needs.tag3.result == 'success' }} - run: git push origin :refs/tags/cmd/genji/"${version}" - name: Discard draft - if: ${{ needs.draft.result == 'success' }} + if: ${{ needs.draft.result == 'success' || needs.draft.outputs.id != '' }} uses: author/action-rollback@v1.0.3 with: release_id: ${{ needs.draft.outputs.id }} + - name: Untag cmd/genji + if: ${{ needs.tag3.result == 'success' }} + uses: author/action-rollback@v1.0.3 + with: + tag: cmd/genji/${{ needs.prepare1.outputs.version }} + delete_orphan_tag: true + - name: Untag badgerengine + if: ${{ needs.tag2.result == 'success' }} + uses: author/action-rollback@v1.0.3 + with: + tag: engine/badgerengine/${{ needs.prepare1.outputs.version }} + delete_orphan_tag: true + - name: Untag genji + if: ${{ needs.tag1.result == 'success' }} + uses: author/action-rollback@v1.0.3 + with: + tag: ${{ needs.prepare1.outputs.version }} + delete_orphan_tag: true From 05f30aca0963a9d8a448f77d5f81f0f3a928d782 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 04:29:11 +0300 Subject: [PATCH 33/54] Oops, fix typo --- .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 837268838..a177476ef 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -331,7 +331,7 @@ jobs: uses: actions/create-release@v1.1.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - env: + with: tag_name: ${{ needs.prepare1.outputs.version }} release_name: ${{ needs.prepare1.outputs.version }} body_path: release.txt From 16e36aba33e9dd5800490bba5a331ddd4f93d895 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 04:32:51 +0300 Subject: [PATCH 34/54] Fix author/action-rollback version --- .github/workflows/release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a177476ef..befd315c2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -353,24 +353,24 @@ jobs: steps: - name: Discard draft if: ${{ needs.draft.result == 'success' || needs.draft.outputs.id != '' }} - uses: author/action-rollback@v1.0.3 + uses: author/action-rollback@1.0.3 with: release_id: ${{ needs.draft.outputs.id }} - name: Untag cmd/genji if: ${{ needs.tag3.result == 'success' }} - uses: author/action-rollback@v1.0.3 + uses: author/action-rollback@1.0.3 with: tag: cmd/genji/${{ needs.prepare1.outputs.version }} delete_orphan_tag: true - name: Untag badgerengine if: ${{ needs.tag2.result == 'success' }} - uses: author/action-rollback@v1.0.3 + uses: author/action-rollback@1.0.3 with: tag: engine/badgerengine/${{ needs.prepare1.outputs.version }} delete_orphan_tag: true - name: Untag genji if: ${{ needs.tag1.result == 'success' }} - uses: author/action-rollback@v1.0.3 + uses: author/action-rollback@1.0.3 with: tag: ${{ needs.prepare1.outputs.version }} delete_orphan_tag: true From 81ea76b55a7e829a3ea9f7f8f6661678b60e56e3 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 04:41:29 +0300 Subject: [PATCH 35/54] Fix author/action-rollback version one more time --- .github/workflows/release.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index befd315c2..7aa07ef66 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -351,26 +351,27 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ always() && !success() }} steps: + # See https://github.com/author/action-rollback/issues/8 - name: Discard draft if: ${{ needs.draft.result == 'success' || needs.draft.outputs.id != '' }} - uses: author/action-rollback@1.0.3 + uses: author/action-rollback@stable with: release_id: ${{ needs.draft.outputs.id }} - name: Untag cmd/genji if: ${{ needs.tag3.result == 'success' }} - uses: author/action-rollback@1.0.3 + uses: author/action-rollback@stable with: tag: cmd/genji/${{ needs.prepare1.outputs.version }} delete_orphan_tag: true - name: Untag badgerengine if: ${{ needs.tag2.result == 'success' }} - uses: author/action-rollback@1.0.3 + uses: author/action-rollback@stable with: tag: engine/badgerengine/${{ needs.prepare1.outputs.version }} delete_orphan_tag: true - name: Untag genji if: ${{ needs.tag1.result == 'success' }} - uses: author/action-rollback@1.0.3 + uses: author/action-rollback@stable with: tag: ${{ needs.prepare1.outputs.version }} delete_orphan_tag: true From a726371d61704a4ac17e501068d2c5cc357021aa Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 04:54:59 +0300 Subject: [PATCH 36/54] =?UTF-8?q?Don=E2=80=99t=20use=20author/action-rollb?= =?UTF-8?q?ack=20for=20untagging,=20meh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yaml | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7aa07ef66..a7fc127b3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -347,31 +347,28 @@ jobs: - tag2 - tag3 - draft - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ always() && !success() }} + env: + version: ${{ needs.prepare1.outputs.version }} steps: - # See https://github.com/author/action-rollback/issues/8 - - name: Discard draft - if: ${{ needs.draft.result == 'success' || needs.draft.outputs.id != '' }} - uses: author/action-rollback@stable - with: - release_id: ${{ needs.draft.outputs.id }} + - name: Checkout code + uses: actions/checkout@v2.3.4 - name: Untag cmd/genji if: ${{ needs.tag3.result == 'success' }} - uses: author/action-rollback@stable - with: - tag: cmd/genji/${{ needs.prepare1.outputs.version }} - delete_orphan_tag: true + run: | + git push origin :refs/tags/cmd/genji/"${version}" - name: Untag badgerengine if: ${{ needs.tag2.result == 'success' }} - uses: author/action-rollback@stable - with: - tag: engine/badgerengine/${{ needs.prepare1.outputs.version }} - delete_orphan_tag: true + run: | + git push origin :refs/tags/engine/badgerengine/"${version}" - name: Untag genji if: ${{ needs.tag1.result == 'success' }} + run: | + git push origin :refs/tags/"${version}" + - name: Discard draft + if: ${{ needs.draft.result == 'success' || needs.draft.outputs.id != '' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: author/action-rollback@stable with: - tag: ${{ needs.prepare1.outputs.version }} - delete_orphan_tag: true + release_id: ${{ needs.draft.outputs.id }} From 77fbbae8a4c0c59544d0a39571d17230c44caa7d Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 05:38:58 +0300 Subject: [PATCH 37/54] Run go mod tidy before releasing root module --- .github/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a7fc127b3..2432b3caf 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -151,6 +151,7 @@ jobs: env: version: ${{ needs.prepare1.outputs.version }} run: | + go mod tidy git commit --allow-empty -m "Bump version to ${version}" git tag "${version}" git push origin "${version}" From bcddd2d5318d8a938fb0173e3df97cdf586276d8 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 18:44:38 +0300 Subject: [PATCH 38/54] Use latest release in development mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that go.mod is always valid so that go get won’t be confused by non-existent v0.0.0-devel version. --- cmd/genji/go.mod | 4 ++-- engine/badgerengine/go.mod | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/genji/go.mod b/cmd/genji/go.mod index c2bb23841..a0517e084 100644 --- a/cmd/genji/go.mod +++ b/cmd/genji/go.mod @@ -6,8 +6,8 @@ require ( github.com/agnivade/levenshtein v1.1.0 github.com/c-bata/go-prompt v0.2.5 github.com/dgraph-io/badger/v3 v3.2011.1 - github.com/genjidb/genji v0.0.0-devel - github.com/genjidb/genji/engine/badgerengine v0.0.0-devel + github.com/genjidb/genji v0.12.0 + github.com/genjidb/genji/engine/badgerengine v0.12.0 github.com/stretchr/testify v1.7.0 github.com/urfave/cli/v2 v2.3.0 go.etcd.io/bbolt v1.3.5 diff --git a/engine/badgerengine/go.mod b/engine/badgerengine/go.mod index b631e2dae..e9e65736e 100644 --- a/engine/badgerengine/go.mod +++ b/engine/badgerengine/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/dgraph-io/badger/v3 v3.2011.1 - github.com/genjidb/genji v0.0.0-devel + github.com/genjidb/genji v0.12.0 github.com/stretchr/testify v1.7.0 ) From 403886d5d890baf9726b419d94c4315bd5d22559 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 18:47:22 +0300 Subject: [PATCH 39/54] Merge tags post-release This should fix release page not showing commits made after release. --- .github/workflows/post-release.yaml | 123 ++++++++++++++++++++++++++++ .github/workflows/release.yaml | 25 +++++- 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/post-release.yaml diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml new file mode 100644 index 000000000..f6c6ddf7c --- /dev/null +++ b/.github/workflows/post-release.yaml @@ -0,0 +1,123 @@ +name: Post-release +on: + workflow_run: + workflows: + - Release + types: + - completed + +env: + # Enable reproducible builds. + GOFLAGS: -trimpath + CGO_ENABLED: '0' + GO_EXTLINK_ENABLED: '0' + +jobs: + # Load version from artifact on successful release. + # + load: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Download artifact + uses: actions/github-script@4.0.2 + env: + run_id: ${{ github.event.workflow_run.id }} + workspace: ${{ github.workspace }} + with: + script: | + const fs = require('fs') + const runID = parseInt(process.env.run_id) + const artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: runID, + }) + const matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == 'version.txt' + })[0] + const download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }) + fs.writeFileSync(`${process.env.workspace}/version.zip`, Buffer.from(download.data)) + - name: Load version + id: version + run: | + unzip version.zip + echo "::set-output name=version::$(cat version.txt)" + + # Merge release tags into release branch. + # + merge: + name: Merge + runs-on: ubuntu-latest + needs: + - load + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.4 + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache + uses: actions/cache@v2.1.5 + with: + path: | + ${{ steps.go-env.outputs.cache }} + ${{ steps.go-env.outputs.modcache }} + key: merge-go-${{ hashFiles('**/go.sum') }} + restore-keys: merge-go- + - name: Set up Git config + run: | + git config user.name actions-user + git config user.email actions@github.com + - name: Merge release + env: + version: ${{ needs.load.outputs.version }} + run: | + git merge \ + refs/tags/${version} \ + refs/tags/engine/badgerengine/${version} \ + refs/tags/cmd/genji/${version} + - name: Add replace directives + run: | + ( + cd engine/badgerengine + go mod edit -replace=github.com/genjidb/genji=../../ + go mod tidy + ) + ( + cd cmd/genji + go mod edit \ + -replace=github.com/genjidb/genji=../../ \ + -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine + go mod tidy + ) + - name: Create PR + uses: peter-evans/create-pull-request@v3.9.2 + with: + author: actions-user + committer: actions-user + commit-message: | + Back to devel mode [skip ci] + base: ${{ github.event.workflow_run.head_branch }} + branch: merge-release-${{ needs.load.outputs.version }} + delete-branch: true + title: 'Merge release tags for ${{ needs.load.outputs.version }}' + body: | + This PR merges ${{ needs.load.outputs.version }} release tags. + + **DO NOT MERGE** if the latest commit does not contain `[skip ci]` and target branch is release branch. Otherwise merge would trigger the release on push event. See https://github.blog/changelog/2021-02-08-github-actions-skip diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2432b3caf..8cbd1cecb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -313,7 +313,7 @@ jobs: git push origin cmd/genji/"${version}" draft: - name: Create Draft + name: Draft release runs-on: ubuntu-latest needs: - prepare1 @@ -339,6 +339,29 @@ jobs: prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} draft: true + # Save version for post-release workflow. + # + save-version: + name: Save version + runs-on: ubuntu-latest + needs: + - prepare1 + steps: + - name: Save version + env: + version: ${{ needs.prepare1.outputs.version }} + run: | + echo "${version}" >version.txt + - name: Upload artifact + uses: actions/upload-artifact@v2.2.3 + with: + name: version.txt + path: version.txt + if-no-files-found: error + retention-days: 1 + + # Remove tags and draft release on failure. + # rollback: name: Rollback runs-on: ubuntu-latest From 3edbd2dd8c7f507fd8d2fdc3fdfcb771ecb1a9c5 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 19:00:23 +0300 Subject: [PATCH 40/54] Fix actions/github-script version --- .github/workflows/post-release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml index f6c6ddf7c..054d3ac5b 100644 --- a/.github/workflows/post-release.yaml +++ b/.github/workflows/post-release.yaml @@ -16,13 +16,14 @@ jobs: # Load version from artifact on successful release. # load: + name: Load version runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Download artifact - uses: actions/github-script@4.0.2 + uses: actions/github-script@v4.0.2 env: run_id: ${{ github.event.workflow_run.id }} workspace: ${{ github.workspace }} From bf86bfaa81d46eabbe77beafaf60071856f67bef Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 19:16:49 +0300 Subject: [PATCH 41/54] Fetch tags in post-release workflow --- .github/workflows/post-release.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml index 054d3ac5b..c05de10ef 100644 --- a/.github/workflows/post-release.yaml +++ b/.github/workflows/post-release.yaml @@ -64,6 +64,8 @@ jobs: uses: actions/checkout@v2.3.4 with: ref: ${{ github.event.workflow_run.head_sha }} + # Fetch all tags too. + fetch-depth: 0 - name: Install Go uses: actions/setup-go@v2.1.3 with: From 3ec7165925d0046cea3916ec61eb4cde7995daba Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 19:34:36 +0300 Subject: [PATCH 42/54] =?UTF-8?q?Don=E2=80=99t=20fetch=20whole=20repo=20hi?= =?UTF-8?q?story=20in=20post-release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/post-release.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml index c05de10ef..c4468cc52 100644 --- a/.github/workflows/post-release.yaml +++ b/.github/workflows/post-release.yaml @@ -64,8 +64,6 @@ jobs: uses: actions/checkout@v2.3.4 with: ref: ${{ github.event.workflow_run.head_sha }} - # Fetch all tags too. - fetch-depth: 0 - name: Install Go uses: actions/setup-go@v2.1.3 with: @@ -87,14 +85,24 @@ jobs: run: | git config user.name actions-user git config user.email actions@github.com + - name: Fetch tags + env: + version: ${{ needs.load.outputs.version }} + run: | + git fetch origin \ + tag ${version} \ + tag engine/badgerengine/${version} \ + tag cmd/genji/${version} - name: Merge release env: version: ${{ needs.load.outputs.version }} run: | + echo "Before merge: $(git rev-parse HEAD)" git merge \ refs/tags/${version} \ refs/tags/engine/badgerengine/${version} \ refs/tags/cmd/genji/${version} + echo "After merge: $(git rev-parse HEAD)" - name: Add replace directives run: | ( @@ -106,7 +114,7 @@ jobs: cd cmd/genji go mod edit \ -replace=github.com/genjidb/genji=../../ \ - -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine + -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine/ go mod tidy ) - name: Create PR @@ -116,7 +124,6 @@ jobs: committer: actions-user commit-message: | Back to devel mode [skip ci] - base: ${{ github.event.workflow_run.head_branch }} branch: merge-release-${{ needs.load.outputs.version }} delete-branch: true title: 'Merge release tags for ${{ needs.load.outputs.version }}' From 76706804b253cc60456ba56b74c16c9a255b1e62 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 20:03:34 +0300 Subject: [PATCH 43/54] Push PR branch explicitly --- .github/workflows/post-release.yaml | 63 +++++++++++++++++------------ 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml index c4468cc52..7a7bef112 100644 --- a/.github/workflows/post-release.yaml +++ b/.github/workflows/post-release.yaml @@ -6,15 +6,7 @@ on: types: - completed -env: - # Enable reproducible builds. - GOFLAGS: -trimpath - CGO_ENABLED: '0' - GO_EXTLINK_ENABLED: '0' - jobs: - # Load version from artifact on successful release. - # load: name: Load version runs-on: ubuntu-latest @@ -52,10 +44,8 @@ jobs: unzip version.zip echo "::set-output name=version::$(cat version.txt)" - # Merge release tags into release branch. - # - merge: - name: Merge + push: + name: Push branch runs-on: ubuntu-latest needs: - load @@ -105,29 +95,52 @@ jobs: echo "After merge: $(git rev-parse HEAD)" - name: Add replace directives run: | + go mod tidy + git add go.mod go.sum ( cd engine/badgerengine go mod edit -replace=github.com/genjidb/genji=../../ go mod tidy + git add go.mod go.sum ) ( cd cmd/genji - go mod edit \ - -replace=github.com/genjidb/genji=../../ \ - -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine/ + go mod edit -replace=github.com/genjidb/genji=../../ + go mod edit -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine/ go mod tidy + git add go.mod go.sum ) + git commit --allow-empty -m 'Add replace directives [skip ci]' + - name: Push PR branch + id: branch + env: + version: ${{ needs.load.outputs.version }} + run: | + branch=merge-release-"${version}" + git checkout -b "${branch}" + git push origin "${branch}" + echo "::set-output name=name::${branch}" + + merge: + name: Create PR + runs-on: ubuntu-latest + needs: + - push + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + with: + ref: ${{ needs.push.outputs.branch }} - name: Create PR - uses: peter-evans/create-pull-request@v3.9.2 + uses: repo-sync/pull-request@v2.4.3 with: - author: actions-user - committer: actions-user - commit-message: | - Back to devel mode [skip ci] - branch: merge-release-${{ needs.load.outputs.version }} - delete-branch: true - title: 'Merge release tags for ${{ needs.load.outputs.version }}' - body: | + source_branch: ${{ needs.push.outputs.branch }} + destination_branch: ${{ github.event.workflow_run.head_branch }} + pr_title: 'Merge release tags for ${{ needs.load.outputs.version }}' + pr_body: | This PR merges ${{ needs.load.outputs.version }} release tags. - **DO NOT MERGE** if the latest commit does not contain `[skip ci]` and target branch is release branch. Otherwise merge would trigger the release on push event. See https://github.blog/changelog/2021-02-08-github-actions-skip + **DO NOT MERGE** if the latest commit does not contain `[skip ci]` and target branch is release branch. + Otherwise merge would trigger the release on push event. + See https://github.blog/changelog/2021-02-08-github-actions-skip + github_token: ${{ secrets.GITHUB_TOKEN }} From 013045d9556b0f4b6860484a539e7623d235ee3b Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 20:22:58 +0300 Subject: [PATCH 44/54] Use gh for post-release pull request --- .github/workflows/post-release.yaml | 38 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml index 7a7bef112..5e5d5013b 100644 --- a/.github/workflows/post-release.yaml +++ b/.github/workflows/post-release.yaml @@ -49,6 +49,8 @@ jobs: runs-on: ubuntu-latest needs: - load + outputs: + branch: ${{ steps.branch.outputs.name }} steps: - name: Checkout code uses: actions/checkout@v2.3.4 @@ -125,22 +127,36 @@ jobs: name: Create PR runs-on: ubuntu-latest needs: + - load - push steps: - - name: Checkout code - uses: actions/checkout@v2.3.4 - with: - ref: ${{ needs.push.outputs.branch }} - name: Create PR - uses: repo-sync/pull-request@v2.4.3 - with: - source_branch: ${{ needs.push.outputs.branch }} - destination_branch: ${{ github.event.workflow_run.head_branch }} - pr_title: 'Merge release tags for ${{ needs.load.outputs.version }}' - pr_body: | + run: gh pr create -R="${repo}" -t="${title}" -b="${body}" -B="${base}" -H="${head}" + env: + repo: ${{ github.repository }} + base: ${{ github.event.workflow_run.head_branch }} + head: ${{ needs.push.outputs.branch }} + title: 'Merge release tags for ${{ needs.load.outputs.version }}' + body: | This PR merges ${{ needs.load.outputs.version }} release tags. **DO NOT MERGE** if the latest commit does not contain `[skip ci]` and target branch is release branch. Otherwise merge would trigger the release on push event. See https://github.blog/changelog/2021-02-08-github-actions-skip - github_token: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + rollback: + name: Rollback + runs-on: ubuntu-latest + needs: + - push + - merge + if: ${{ always() && !success() }} + env: + branch: ${{ needs.push.outputs.branch }} + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Delete branch + if: ${{ needs.push.result == 'success' }} + run: git push origin :refs/heads/"${branch}" From bc8c26c51a506620719e17ecde2baad9829a818f Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 20:29:36 +0300 Subject: [PATCH 45/54] Checkout code before creating PR --- .github/workflows/post-release.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml index 5e5d5013b..6305879b8 100644 --- a/.github/workflows/post-release.yaml +++ b/.github/workflows/post-release.yaml @@ -130,6 +130,8 @@ jobs: - load - push steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 - name: Create PR run: gh pr create -R="${repo}" -t="${title}" -b="${body}" -B="${base}" -H="${head}" env: From 0a624784593e7cd44d7e088064c8ee50d200b341 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 20:39:42 +0300 Subject: [PATCH 46/54] =?UTF-8?q?Ensure=20that=20release=20won=E2=80=99t?= =?UTF-8?q?=20run=20for=20tags=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/post-release.yaml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml index 6305879b8..b309079be 100644 --- a/.github/workflows/post-release.yaml +++ b/.github/workflows/post-release.yaml @@ -82,18 +82,18 @@ jobs: version: ${{ needs.load.outputs.version }} run: | git fetch origin \ - tag ${version} \ - tag engine/badgerengine/${version} \ - tag cmd/genji/${version} + tag "${version}" \ + tag engine/badgerengine/"${version}" \ + tag cmd/genji/"${version}" - name: Merge release env: version: ${{ needs.load.outputs.version }} run: | echo "Before merge: $(git rev-parse HEAD)" git merge \ - refs/tags/${version} \ - refs/tags/engine/badgerengine/${version} \ - refs/tags/cmd/genji/${version} + refs/tags/"${version}" \ + refs/tags/engine/badgerengine/"${version}" \ + refs/tags/cmd/genji/"${version}" echo "After merge: $(git rev-parse HEAD)" - name: Add replace directives run: | @@ -138,13 +138,11 @@ jobs: repo: ${{ github.repository }} base: ${{ github.event.workflow_run.head_branch }} head: ${{ needs.push.outputs.branch }} - title: 'Merge release tags for ${{ needs.load.outputs.version }}' + # Ensure that default PR merge commit body contains [skip ci] so that we don’t trigger release workflow. + # See https://github.blog/changelog/2021-02-08-github-actions-skip + title: 'Merge release tags for ${{ needs.load.outputs.version }} [skip ci]' body: | This PR merges ${{ needs.load.outputs.version }} release tags. - - **DO NOT MERGE** if the latest commit does not contain `[skip ci]` and target branch is release branch. - Otherwise merge would trigger the release on push event. - See https://github.blog/changelog/2021-02-08-github-actions-skip GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} rollback: From 05189836431c159310bf72c0e3ca017f8ec4f3a7 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 20:50:28 +0300 Subject: [PATCH 47/54] Move base version input below new version --- .github/workflows/release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8cbd1cecb..44c9c7034 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,14 +6,14 @@ on: - release-v* workflow_dispatch: inputs: - base: - description: 'Base version' - required: false - default: '' version: description: 'New version' required: false default: '' + base: + description: 'Base version' + required: false + default: '' env: # Ensure that we have a chance to remove tags for failed release From e1031e5834d67e1e693b75ffee09992f29b565e2 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 21:03:38 +0300 Subject: [PATCH 48/54] Merge post-release into release workflow --- .github/workflows/post-release.yaml | 162 ---------------------------- .github/workflows/release.yaml | 115 +++++++++++++++++--- 2 files changed, 102 insertions(+), 175 deletions(-) delete mode 100644 .github/workflows/post-release.yaml diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml deleted file mode 100644 index b309079be..000000000 --- a/.github/workflows/post-release.yaml +++ /dev/null @@ -1,162 +0,0 @@ -name: Post-release -on: - workflow_run: - workflows: - - Release - types: - - completed - -jobs: - load: - name: Load version - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Download artifact - uses: actions/github-script@v4.0.2 - env: - run_id: ${{ github.event.workflow_run.id }} - workspace: ${{ github.workspace }} - with: - script: | - const fs = require('fs') - const runID = parseInt(process.env.run_id) - const artifacts = await github.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: runID, - }) - const matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == 'version.txt' - })[0] - const download = await github.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }) - fs.writeFileSync(`${process.env.workspace}/version.zip`, Buffer.from(download.data)) - - name: Load version - id: version - run: | - unzip version.zip - echo "::set-output name=version::$(cat version.txt)" - - push: - name: Push branch - runs-on: ubuntu-latest - needs: - - load - outputs: - branch: ${{ steps.branch.outputs.name }} - steps: - - name: Checkout code - uses: actions/checkout@v2.3.4 - with: - ref: ${{ github.event.workflow_run.head_sha }} - - name: Install Go - uses: actions/setup-go@v2.1.3 - with: - go-version: 1.16.4 - - name: Get Go environment - id: go-env - run: | - echo "::set-output name=cache::$(go env GOCACHE)" - echo "::set-output name=modcache::$(go env GOMODCACHE)" - - name: Set up cache - uses: actions/cache@v2.1.5 - with: - path: | - ${{ steps.go-env.outputs.cache }} - ${{ steps.go-env.outputs.modcache }} - key: merge-go-${{ hashFiles('**/go.sum') }} - restore-keys: merge-go- - - name: Set up Git config - run: | - git config user.name actions-user - git config user.email actions@github.com - - name: Fetch tags - env: - version: ${{ needs.load.outputs.version }} - run: | - git fetch origin \ - tag "${version}" \ - tag engine/badgerengine/"${version}" \ - tag cmd/genji/"${version}" - - name: Merge release - env: - version: ${{ needs.load.outputs.version }} - run: | - echo "Before merge: $(git rev-parse HEAD)" - git merge \ - refs/tags/"${version}" \ - refs/tags/engine/badgerengine/"${version}" \ - refs/tags/cmd/genji/"${version}" - echo "After merge: $(git rev-parse HEAD)" - - name: Add replace directives - run: | - go mod tidy - git add go.mod go.sum - ( - cd engine/badgerengine - go mod edit -replace=github.com/genjidb/genji=../../ - go mod tidy - git add go.mod go.sum - ) - ( - cd cmd/genji - go mod edit -replace=github.com/genjidb/genji=../../ - go mod edit -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine/ - go mod tidy - git add go.mod go.sum - ) - git commit --allow-empty -m 'Add replace directives [skip ci]' - - name: Push PR branch - id: branch - env: - version: ${{ needs.load.outputs.version }} - run: | - branch=merge-release-"${version}" - git checkout -b "${branch}" - git push origin "${branch}" - echo "::set-output name=name::${branch}" - - merge: - name: Create PR - runs-on: ubuntu-latest - needs: - - load - - push - steps: - - name: Checkout code - uses: actions/checkout@v2.3.4 - - name: Create PR - run: gh pr create -R="${repo}" -t="${title}" -b="${body}" -B="${base}" -H="${head}" - env: - repo: ${{ github.repository }} - base: ${{ github.event.workflow_run.head_branch }} - head: ${{ needs.push.outputs.branch }} - # Ensure that default PR merge commit body contains [skip ci] so that we don’t trigger release workflow. - # See https://github.blog/changelog/2021-02-08-github-actions-skip - title: 'Merge release tags for ${{ needs.load.outputs.version }} [skip ci]' - body: | - This PR merges ${{ needs.load.outputs.version }} release tags. - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - rollback: - name: Rollback - runs-on: ubuntu-latest - needs: - - push - - merge - if: ${{ always() && !success() }} - env: - branch: ${{ needs.push.outputs.branch }} - steps: - - name: Checkout code - uses: actions/checkout@v2.3.4 - - name: Delete branch - if: ${{ needs.push.result == 'success' }} - run: git push origin :refs/heads/"${branch}" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 44c9c7034..686a4ad58 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,6 +30,7 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.changelog.outputs.version }} + branch: ${{ steps.version.outputs.branch }} steps: - name: Checkout code uses: actions/checkout@v2.3.4 @@ -76,6 +77,7 @@ jobs: fi echo "::set-output name=base::${base}" echo "::set-output name=next::${next}" + echo "::set-output name=branch::${branch}" # Check github.com/genjidb/genji module. # @@ -339,26 +341,107 @@ jobs: prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} draft: true - # Save version for post-release workflow. - # - save-version: - name: Save version + push: + name: Push branch runs-on: ubuntu-latest needs: - prepare1 + - tag1 + - tag2 + - tag3 + outputs: + branch: ${{ steps.branch.outputs.name }} steps: - - name: Save version + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Install Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16.4 + - name: Get Go environment + id: go-env + run: | + echo "::set-output name=cache::$(go env GOCACHE)" + echo "::set-output name=modcache::$(go env GOMODCACHE)" + - name: Set up cache + uses: actions/cache@v2.1.5 + with: + path: | + ${{ steps.go-env.outputs.cache }} + ${{ steps.go-env.outputs.modcache }} + key: push-go-${{ hashFiles('**/go.sum') }} + restore-keys: push-go- + - name: Set up Git config + run: | + git config user.name actions-user + git config user.email actions@github.com + - name: Fetch tags env: version: ${{ needs.prepare1.outputs.version }} run: | - echo "${version}" >version.txt - - name: Upload artifact - uses: actions/upload-artifact@v2.2.3 - with: - name: version.txt - path: version.txt - if-no-files-found: error - retention-days: 1 + git fetch origin \ + tag "${version}" \ + tag engine/badgerengine/"${version}" \ + tag cmd/genji/"${version}" + - name: Merge release + env: + version: ${{ needs.prepare1.outputs.version }} + run: | + echo "Before merge: $(git rev-parse HEAD)" + git merge \ + refs/tags/"${version}" \ + refs/tags/engine/badgerengine/"${version}" \ + refs/tags/cmd/genji/"${version}" + echo "After merge: $(git rev-parse HEAD)" + - name: Add replace directives + run: | + go mod tidy + git add go.mod go.sum + ( + cd engine/badgerengine + go mod edit -replace=github.com/genjidb/genji=../../ + go mod tidy + git add go.mod go.sum + ) + ( + cd cmd/genji + go mod edit -replace=github.com/genjidb/genji=../../ + go mod edit -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine/ + go mod tidy + git add go.mod go.sum + ) + git commit --allow-empty -m 'Add replace directives [skip ci]' + - name: Push PR branch + id: branch + env: + version: ${{ needs.prepare1.outputs.version }} + run: | + branch=merge-release-"${version}" + git checkout -b "${branch}" + git push origin "${branch}" + echo "::set-output name=name::${branch}" + + merge: + name: Create PR + runs-on: ubuntu-latest + needs: + - prepare1 + - push + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + - name: Create PR + run: gh pr create -R="${repo}" -t="${title}" -b="${body}" -B="${base}" -H="${head}" + env: + repo: ${{ github.repository }} + base: ${{ needs.prepare1.outputs.branch }} + head: ${{ needs.push.outputs.branch }} + # Ensure that default merge commit body contains [skip ci] so that we don’t trigger release workflow. + # See also https://github.blog/changelog/2021-02-08-github-actions-skip + title: 'Merge release tags for ${{ needs.prepare1.outputs.version }} [skip ci]' + body: | + This PR merges ${{ needs.prepare1.outputs.version }} release tags. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Remove tags and draft release on failure. # @@ -370,13 +453,19 @@ jobs: - tag1 - tag2 - tag3 + - push - draft if: ${{ always() && !success() }} env: + branch: ${{ needs.push.outputs.branch }} version: ${{ needs.prepare1.outputs.version }} steps: - name: Checkout code uses: actions/checkout@v2.3.4 + - name: Delete PR branch + if: ${{ needs.push.result == 'success' || needs.push.outputs.branch != '' }} + run: | + git push origin :refs/heads/"${branch}" - name: Untag cmd/genji if: ${{ needs.tag3.result == 'success' }} run: | From 54809389bb1c5085ff3ec40424afdd89bdcd90b4 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 21:12:54 +0300 Subject: [PATCH 49/54] Log git diff output before commit --- .github/workflows/release.yaml | 17 +++++++++++------ cmd/genji/go.mod | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 686a4ad58..278389249 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -154,6 +154,8 @@ jobs: version: ${{ needs.prepare1.outputs.version }} run: | go mod tidy + git diff + git add go.mod go.sum git commit --allow-empty -m "Bump version to ${version}" git tag "${version}" git push origin "${version}" @@ -261,6 +263,7 @@ jobs: go mod edit -dropreplace=github.com/genjidb/genji go mod edit -require=github.com/genjidb/genji@"${version}" go mod tidy + git diff git add go.mod go.sum git commit --allow-empty -m "Bump version to ${version}" git tag engine/badgerengine/"${version}" @@ -302,13 +305,12 @@ jobs: env: version: ${{ needs.prepare1.outputs.version }} run: | - go mod edit \ - -dropreplace=github.com/genjidb/genji \ - -dropreplace=github.com/genjidb/genji/engine/badgerengine - go mod edit \ - -require=github.com/genjidb/genji@"${version}" \ - -require=github.com/genjidb/genji/engine/badgerengine@"${version}" + go mod edit -dropreplace=github.com/genjidb/genji + go mod edit -dropreplace=github.com/genjidb/genji/engine/badgerengine + go mod edit -require=github.com/genjidb/genji@"${version}" + go mod edit -require=github.com/genjidb/genji/engine/badgerengine@"${version}" go mod tidy + git diff git add go.mod go.sum git commit --allow-empty -m "Bump version to ${version}" git tag cmd/genji/"${version}" @@ -396,11 +398,13 @@ jobs: - name: Add replace directives run: | go mod tidy + git diff git add go.mod go.sum ( cd engine/badgerengine go mod edit -replace=github.com/genjidb/genji=../../ go mod tidy + git diff git add go.mod go.sum ) ( @@ -408,6 +412,7 @@ jobs: go mod edit -replace=github.com/genjidb/genji=../../ go mod edit -replace=github.com/genjidb/genji/engine/badgerengine=../../engine/badgerengine/ go mod tidy + git diff git add go.mod go.sum ) git commit --allow-empty -m 'Add replace directives [skip ci]' diff --git a/cmd/genji/go.mod b/cmd/genji/go.mod index a0517e084..04b6c4934 100644 --- a/cmd/genji/go.mod +++ b/cmd/genji/go.mod @@ -17,5 +17,5 @@ require ( replace ( github.com/genjidb/genji => ../../ - github.com/genjidb/genji/engine/badgerengine => ../../engine/badgerengine + github.com/genjidb/genji/engine/badgerengine => ../../engine/badgerengine/ ) From 1edee9c513f82afbb052e20d28d1f6809b29944d Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 21:20:06 +0300 Subject: [PATCH 50/54] Set GOPRIVATE in release-assets workflow --- .github/workflows/release-assets.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index 645d4b82e..12d24b745 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -5,6 +5,9 @@ on: - published env: + # Ensure that we still have a chance to remove tags event after release. + # See also release.yaml. + GOPRIVATE: github.com/genjidb/genji # Enable reproducible builds. GOFLAGS: -trimpath CGO_ENABLED: '0' From 4c30c21019f6a69cf4f47bd0d83c8b8f5613573e Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 21:26:32 +0300 Subject: [PATCH 51/54] Set commitish to main on release --- .github/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 278389249..92061de76 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -342,6 +342,7 @@ jobs: body_path: release.txt prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} draft: true + commitish: main push: name: Push branch From 3c5571e27716a64556bb5d4b2611f58424f73037 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 21:38:15 +0300 Subject: [PATCH 52/54] Run rollback after merge --- .github/workflows/release.yaml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 92061de76..814d93e6b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -342,6 +342,10 @@ jobs: body_path: release.txt prerelease: ${{ contains(needs.prepare1.outputs.version, '-') }} draft: true + # Defaults to HEAD unless we set that explicitly. Setting this + # to main branch fixes “commits since release” on release page. + # Ideally we could just use gh but that would just make things + # harder since we need release ID for rollback job on failure. commitish: main push: @@ -460,6 +464,7 @@ jobs: - tag2 - tag3 - push + - merge - draft if: ${{ always() && !success() }} env: @@ -468,6 +473,13 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2.3.4 + - name: Discard draft + if: ${{ needs.draft.result == 'success' || needs.draft.outputs.id != '' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: author/action-rollback@stable + with: + release_id: ${{ needs.draft.outputs.id }} - name: Delete PR branch if: ${{ needs.push.result == 'success' || needs.push.outputs.branch != '' }} run: | @@ -484,10 +496,3 @@ jobs: if: ${{ needs.tag1.result == 'success' }} run: | git push origin :refs/tags/"${version}" - - name: Discard draft - if: ${{ needs.draft.result == 'success' || needs.draft.outputs.id != '' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: author/action-rollback@stable - with: - release_id: ${{ needs.draft.outputs.id }} From 8141e33e4050233db2702295e9a788174d801a7a Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 15 May 2021 22:15:01 +0300 Subject: [PATCH 53/54] Update .github/workflows/release-assets.yaml --- .github/workflows/release-assets.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index 12d24b745..1608b4643 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -5,7 +5,7 @@ on: - published env: - # Ensure that we still have a chance to remove tags event after release. + # Ensure that we still have a chance to remove tags even after release. # See also release.yaml. GOPRIVATE: github.com/genjidb/genji # Enable reproducible builds. From 36ce470937472e3daf89ba2377f8828ea600022b Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Mon, 17 May 2021 04:32:47 +0300 Subject: [PATCH 54/54] Set concurrency group in release workflow --- .github/workflows/release.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 814d93e6b..ca132fe84 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,6 +24,9 @@ env: CGO_ENABLED: '0' GO_EXTLINK_ENABLED: '0' +concurrency: + group: release + jobs: prepare1: name: Prepare genji