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

Use "GoReleaser" #395

Merged
merged 24 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0fa0d14
goreleaser init
brandonbloom Oct 5, 2021
99f437a
WIP configuring goreleaser
brandonbloom Oct 5, 2021
32a67c7
Merge remote-tracking branch 'origin/main' into releaser
BenElgar Oct 19, 2021
ea4b35e
Track go releaser
BenElgar Oct 19, 2021
47be021
Fix bad binary path
BenElgar Oct 19, 2021
9bc6dd9
Remove bad directory from gitignore
BenElgar Oct 19, 2021
d8e98e1
Support managed builds, build for linux and use github release
BenElgar Oct 20, 2021
dfbf8e9
Update github actions workflows
BenElgar Oct 20, 2021
2a1e543
Remove replacements entirely
BenElgar Oct 20, 2021
fc702f3
Re-enable GUI build and build with CGO
BenElgar Oct 21, 2021
d253718
Merge remote-tracking branch 'origin/main' into releaser
BenElgar Oct 21, 2021
39ed5dd
Install and build sqlite3 outside of main build
BenElgar Oct 21, 2021
8166041
Rename autoinstalled to standalone and remove 386 build
BenElgar Oct 21, 2021
80f4b8d
Build with CGO_ENABLED
BenElgar Oct 21, 2021
238c214
Merge remote-tracking branch 'origin/main' into releaser
BenElgar Oct 21, 2021
bc06af0
Remove tools
BenElgar Oct 21, 2021
4696adb
Run go mod tidy
BenElgar Oct 21, 2021
e5bc118
Set netgo tag
BenElgar Oct 21, 2021
e155141
Remove obsolete comment
BenElgar Oct 21, 2021
c90c6d4
Merge remote-tracking branch 'origin/main' into releaser
BenElgar Oct 22, 2021
240fd9d
Add release to makefile
BenElgar Oct 22, 2021
3361f7e
Pas GITHUB_TOKEN
BenElgar Oct 22, 2021
d1cd7aa
Set up node for release
BenElgar Oct 22, 2021
3144dc8
Merge release actions
BenElgar Oct 25, 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
46 changes: 46 additions & 0 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
push:
tags:
- "v*"

# Needed to create a Github release with archives.
#permissions:
# contents: write
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably you need to uncomment this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was going to see if it worked without it before I set that flag.


jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO: Need a custom personal access token to allow publishing to
# the deref/homebrew-tap repository.
# GITHUB_TOKEN: ${{ secrets.GH_PAT }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: Get version from VERSION file
id: get_version
run: echo ::set-output name=release_version::$(cat VERSION | tr -d '[:space:]')

- name: Update version in CloudFlare K/V
uses: cloudflare/wrangler-action@1.3.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
publish: false
preCommands: wrangler kv:key put --binding VERSIONS "exo" ${{ steps.get_version.outputs.release_version }}
127 changes: 0 additions & 127 deletions .github/workflows/perform-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,130 +50,3 @@ jobs:
ref: `refs/tags/v${version}`,
sha: context.sha
})

create-release:
name: Create a GH release from version tag
runs-on: ubuntu-latest
needs:
- create-release-tag
steps:
- uses: actions/checkout@v2
- name: Get version from VERSION file
id: get_version
run: |
echo ::set-output name=release_version::$(cat VERSION | tr -d '[:space:]')
- name: Create release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.release_version }}
release_name: Release ${{ steps.get_version.outputs.release_version }}
draft: false
prerelease: false
- name: Output release URL file
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save release URL file for publish
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt

publish-binaries:
runs-on: ubuntu-latest
needs:
- create-release
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: 15.x
- run: npm ci
working-directory: gui
- run: npm run build
working-directory: gui

- name: Get version from VERSION file
id: get_version
run: echo ::set-output name=release_version::$(cat VERSION | tr -d '[:space:]')
- name: Load release URL file from release job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Set environment variables
env:
REPOSITORY_NAME: ${{ github.repository }}
ARTIFACT_DIR: ./artifacts
run: |
export BASE_NAME=${REPOSITORY_NAME##*/}
export BINARY_NAME="${BASE_NAME}-${{ steps.get_version.outputs.release_version }}-${{ matrix.goos }}-${{ matrix.goarch }}"
echo "binary_name=$BINARY_NAME" >> $GITHUB_ENV
echo "artifact_dir=$ARTIFACT_DIR" >> $GITHUB_ENV
echo "binary_path=${ARTIFACT_DIR}/${BINARY_NAME}" >> $GITHUB_ENV
- name: Build
run: |
mkdir -p "${{ env.artifact_dir }}"
go build .
docker run \
-e GOOS=${{ matrix.goos }} \
-e GOARCH=${{ matrix.goarch }} \
--mount "type=bind,source=${PWD},target=/go/src/exo" \
--mount "type=bind,source=${HOME}/go/pkg/mod,target=/go/pkg/mod" \
-w /go/src/exo \
ghcr.io/deref/golang-cross \
go build \
-tags bundle \
-o "${{ env.binary_path }}" \
.
sha256sum "${{ env.binary_path }}" | cut -d ' ' -f 1 > "${{ env.binary_path }}.sha256"
- name: Set upload URL
id: get_release_info
run: |
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
- name: Upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ env.binary_path }}
asset_name: ${{ env.binary_name }}
asset_content_type: application/octet-stream
- name: Upload release SHA256 hash
id: upload-release-checksum
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ env.binary_path }}.sha256
asset_name: ${{ env.binary_name }}.sha256
asset_content_type: text/plain

update-version:
runs-on: ubuntu-latest
needs:
- publish-binaries
steps:
- uses: actions/checkout@v2
- name: Get version from VERSION file
id: get_version
run: echo ::set-output name=release_version::$(cat VERSION | tr -d '[:space:]')
- name: Update version in CloudFlare K/V
uses: cloudflare/wrangler-action@1.3.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
publish: false
preCommands: wrangler kv:key put --binding VERSIONS "exo" ${{ steps.get_version.outputs.release_version }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/.vscode/
/bin
.DS_Store
/exo
/dist/
*.tsbuildinfo
90 changes: 90 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Documentation for .goreleaser.yml can be found at <https://goreleaser.com>.
---
before:
hooks:
- go mod tidy
- make codegen
#- make -C gui
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, need to uncomment that — I just disabled it for testing.

env:
- CGO_ENABLED=0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CGO_ENABLED is not 1, the build will succeed, but as soon as you try to open a Sqlite database, you'll encounter an error saying that CGO must be enabled.

builds:
# This is the build for use in the install script.
- id: autoinstalled
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit picky: seems like an odd name for this. Does this name show up anywhere else? Like in the built files or whatever?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "standalone"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was using the names from the files in ./internal/upgrade. Happy to change it to standalone though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think "standalone" is much clearer to me. Please change. Thanks!

main: .
goos:
- linux
- darwin
tags:
- bundle

# This is the build for use by package managers.
- id: managed
main: .
goos:
Copy link
Member Author

@brandonbloom brandonbloom Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to goos, we also need to build for goarch set to both amd64 and arm64, at least on darwin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is to build for arm64, amd64 and i386: https://goreleaser.com/customization/build/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need i386 support? Seems like that's extremely unlikely for any developer machine these days.

I'd suggest dropping that and making this configuration explicit.

- linux
- darwin
tags:
- bundle
- managed

archives:
- id: autoinstalled
name_template: '{{ .ProjectName }}_autoinstalled_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
builds: ["autoinstalled"]
wrap_in_directory: true
files:
- LICENSE
- NOTICES.md
- VERSION
- README.md
- doc/*
- id: managed
name_template: '{{ .ProjectName }}_managed_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
builds: ["managed"]
wrap_in_directory: true
files:
- LICENSE
- NOTICES.md
- VERSION
- README.md
- doc/*

checksum:
name_template: "checksums.txt"

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

brews:
- name: exo
ids: ["managed"]
tap:
owner: deref
name: homebrew-tap
commit_author:
name: derefbot
email: bot@deref.io
homepage: "https://exo.deref.io"
folder: Formula
test: |
system "#{bin}/exo version"

nfpms:
- builds: ["managed"]
formats:
- apk
- deb
- rpm

release:
github:
owner: deref
name: exo
disable: true
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/go-git/go-git/v5 v5.4.2
github.com/goccy/go-yaml v1.8.10
github.com/gofrs/flock v0.8.1
github.com/goreleaser/goreleaser v0.136.0
github.com/hashicorp/hcl/v2 v2.10.0
github.com/influxdata/go-syslog/v3 v3.0.0
github.com/jmoiron/sqlx v1.2.1-0.20190826204134-d7d95172beb5
Expand Down
Loading