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 all 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
131 changes: 19 additions & 112 deletions .github/workflows/perform-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Create tag
uses: actions/github-script@v3
with:
Expand All @@ -49,131 +50,37 @@ jobs:
repo: context.repo.repo,
ref: `refs/tags/v${version}`,
sha: context.sha
})
- run: git tag ${{ steps.get_version.outputs.release_version }}

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 }}
- name: Set up Go
uses: actions/setup-go@v2
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
go-version: 1.17

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
- uses: actions/setup-node@v2
with:
go-version: 1.16

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: 15.x
node-version: 'lts/*'
cache: 'npm'
cache-dependency-path: "gui/package-lock.json"
- run: npm i -g npm@latest
- run: npm ci
working-directory: gui
- run: npm run build
working-directory: gui
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

- name: Run GoReleaser
run: make release
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
# Need a custom personal access token to allow publishing to
# the deref/homebrew-tap repository.
GITHUB_TOKEN: ${{ secrets.GH_PAT }}


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 }}
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
159 changes: 159 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Documentation for .goreleaser.yml can be found at <https://goreleaser.com>.
---
env:
- CGO_ENABLED=1
builds:
- id: linux-arm64-standalone
main: .
flags: ["-mod=readonly"]
goos: ["linux"]
goarch: ["arm64"]
ldflags: ['-extldflags=-static']
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
tags:
- netgo
- bundle
- id: linux-amd64-standalone
main: .
flags: ["-mod=readonly"]
goos: ["linux"]
goarch: ["amd64"]
ldflags: ['-extldflags=-static']
env:
- CC=gcc
- CXX=g++
tags:
- netgo
- bundle
- id: linux-arm64-managed
main: .
flags: ["-mod=readonly"]
goos: ["linux"]
goarch: ["arm64"]
ldflags: ['-extldflags=-static']
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
tags:
- netgo
- bundle
- managed
- id: linux-amd64-managed
main: .
flags: ["-mod=readonly"]
goos: ["linux"]
goarch: ["amd64"]
ldflags: ['-extldflags=-static']
env:
- CC=gcc
- CXX=g++
tags:
- netgo
- bundle
- managed
- id: darwin-arm64-standalone
main: .
flags: ["-mod=readonly"]
goos: ["darwin"]
goarch: ["arm64"]
env:
- CC=oa64-clang
- CXX=oa64-clang++
tags:
- netgo
- bundle
- id: darwin-amd64-standalone
main: .
flags: ["-mod=readonly"]
goos: ["darwin"]
goarch: ["amd64"]
env:
- CC=oa64-clang
- CXX=oa64-clang++
tags:
- netgo
- bundle
- id: darwin-arm64-managed
main: .
flags: ["-mod=readonly"]
goos: ["darwin"]
goarch: ["arm64"]
env:
- CC=oa64-clang
- CXX=oa64-clang++
tags:
- netgo
- bundle
- managed
- id: darwin-amd64-managed
main: .
flags: ["-mod=readonly"]
goos: ["darwin"]
goarch: ["amd64"]
env:
- CC=oa64-clang
- CXX=oa64-clang++
tags:
- netgo
- bundle
- managed

archives:
- id: standalone
name_template: '{{ .ProjectName }}_standalone_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
builds:
- linux-arm64-standalone
- linux-amd64-standalone
- darwin-arm64-standalone
- darwin-amd64-standalone
- id: managed
name_template: '{{ .ProjectName }}_managed_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
builds:
- linux-arm64-managed
- linux-amd64-managed
- darwin-arm64-managed
- darwin-amd64-managed

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:
- linux-arm64-managed
- linux-amd64-managed
formats:
- apk
- deb
- rpm

release:
github:
owner: deref
name: exo
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
PACKAGE_NAME := github.com/deref/exo
GOLANG_CROSS_VERSION ?= v1.17.2

.PHONY: all
all:
$(MAKE) codegen
Expand All @@ -14,3 +17,32 @@ bin/exo:
.PHONY: codegen
codegen:
./script/codegen.sh

.PHONY: make-gui
make-gui:
make -C gui

.PHONY: mod-tidy
mod-tidy:
go mod tidy

.PHONY: release-dry-run
release-dry-run: make-gui mod-tidy codegen
@docker run \
--privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/troian/golang-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish

.PHONY: release
release: make-gui mod-tidy codegen
@docker run \
--privileged \
-e GITHUB_TOKEN \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/troian/golang-cross:${GOLANG_CROSS_VERSION} \
--rm-dist
Loading