Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate releases #401

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
13ad072
Run go mod tidy
tie May 13, 2021
2ff5fbe
Remove explicit versions from replace directives
tie May 13, 2021
d63e4ec
Added release workflow
tie May 13, 2021
aead527
Update .github/workflows/release-assets.yaml
tie May 14, 2021
b75dd62
Update .github/workflows/release.yaml
tie May 14, 2021
82618cb
Add files generated in release workflow to gitignore
tie May 14, 2021
c2e7d10
Allow pushing to release branch with explicit version
tie May 14, 2021
7530992
Add android/arm64 to build matrix
tie May 14, 2021
eb59a82
Fix badgerengine replace path in release workflow
tie May 14, 2021
5b6e2fb
Use go mod edit -require instead of go get
tie May 14, 2021
28a539d
Use gh for releases instead of deprecated action
tie May 14, 2021
f423b05
Set PR base to main branch
tie May 14, 2021
3983b87
Use gh for release workflow pull request
tie May 14, 2021
c7e1ec5
Don’t set label on release pull request
tie May 14, 2021
2611157
Don’t run fuzz workflow for release branch
tie May 14, 2021
b9da340
Create empty commit for root module version bump
tie May 14, 2021
e1c7ecb
Remove PR creation step
tie May 14, 2021
eb94716
Tag commits in separate jobs
tie May 14, 2021
e003170
Always use v0.0.0-devel for replaced modules
tie May 14, 2021
0135b07
Make job names shorter
tie May 14, 2021
f51b862
Remove no-op step from prepare job
tie May 14, 2021
3d1dcd1
Add dependabot config for actions
tie May 14, 2021
65c7311
Rollback release on failure
tie May 14, 2021
fb0cb91
Change some step names
tie May 14, 2021
77f06ec
Generate changelog for badgerengine after tagging root module
tie May 15, 2021
f7c07c2
Fix changelog path for badgerengine
tie May 15, 2021
982d73f
Use go1.16.4 in actions
tie May 15, 2021
dfa8155
Use even shorter job names in release workflow
tie May 15, 2021
bcd3839
Use shorter step names
tie May 15, 2021
9613e52
Rollback from separate job
tie May 15, 2021
c70a558
Also rollback draft release on failure
tie May 15, 2021
6d41416
Use author/action-rollback for untagging
tie May 15, 2021
05f30ac
Oops, fix typo
tie May 15, 2021
16e36ab
Fix author/action-rollback version
tie May 15, 2021
81ea76b
Fix author/action-rollback version one more time
tie May 15, 2021
a726371
Don’t use author/action-rollback for untagging, meh
tie May 15, 2021
77fbbae
Run go mod tidy before releasing root module
tie May 15, 2021
bcddd2d
Use latest release in development mode
tie May 15, 2021
403886d
Merge tags post-release
tie May 15, 2021
3edbd2d
Fix actions/github-script version
tie May 15, 2021
bf86bfa
Fetch tags in post-release workflow
tie May 15, 2021
3ec7165
Don’t fetch whole repo history in post-release
tie May 15, 2021
7670680
Push PR branch explicitly
tie May 15, 2021
013045d
Use gh for post-release pull request
tie May 15, 2021
bc8c26c
Checkout code before creating PR
tie May 15, 2021
0a62478
Ensure that release won’t run for tags merge
tie May 15, 2021
0518983
Move base version input below new version
tie May 15, 2021
e1031e5
Merge post-release into release workflow
tie May 15, 2021
5480938
Log git diff output before commit
tie May 15, 2021
1edee9c
Set GOPRIVATE in release-assets workflow
tie May 15, 2021
4c30c21
Set commitish to main on release
tie May 15, 2021
3c5571e
Run rollback after merge
tie May 15, 2021
8141e33
Update .github/workflows/release-assets.yaml
tie May 15, 2021
36ce470
Set concurrency group in release workflow
tie May 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions .github/workflows/release-assets.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]/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/[email protected]
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/[email protected]
with:
path: ${{ steps.go-env.outputs.modcache }}
key: modcache-go-${{ hashFiles('**/go.sum') }}
restore-keys: modcache-go-

- name: Set up build cache
uses: actions/[email protected]
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 }}
tie marked this conversation as resolved.
Show resolved Hide resolved

- 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 }}
172 changes: 172 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- name: Install Go
uses: actions/[email protected]
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/[email protected]
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/[email protected]

- name: Set up Git config
run: |
git config user.name actions-user
git config user.email [email protected]

# 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=../../
tie marked this conversation as resolved.
Show resolved Hide resolved
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/[email protected]
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/[email protected]
with:
author: GitHub <[email protected]>
committer: GitHub <[email protected]>
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 }}
4 changes: 2 additions & 2 deletions cmd/genji/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
1 change: 1 addition & 0 deletions cmd/genji/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion engine/badgerengine/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ../../
1 change: 1 addition & 0 deletions engine/badgerengine/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down