forked from chaisql/chai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
name: Release Assets | ||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
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' }} | ||
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 }} | ||
|
||
- 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=../../ | ||
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 }} |