-
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.
CI/CD for building cloudcored and cloudcore server
- Loading branch information
Showing
16 changed files
with
450 additions
and
33 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,48 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
# run only against tags | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
issues: write | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- run: git fetch --force --tags | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
# More assembly might be required: Docker logins, GPG, etc. | ||
# It all depends on your needs. | ||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v2 | ||
- name: Code Generation | ||
run: | | ||
go install google.golang.org/protobuf/cmd/[email protected] | ||
go install google.golang.org/grpc/cmd/[email protected] | ||
go generate ./... | ||
- uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
# either 'goreleaser' (default) or 'goreleaser-pro': | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean | ||
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,58 @@ | ||
builds: | ||
- id: cloudcored | ||
main: ./cmd/cloudcored | ||
binary: cloudcored | ||
ldflags: | ||
- -s -w -X github.com/clarkmcc/cloudcore/pkg/version.Version={{.Version}} -X github.com/clarkmcc/cloudcore/pkg/version.Hash={{.Commit}} | ||
env: | ||
- CGO_ENABLED=0 | ||
targets: | ||
- darwin_amd64 | ||
- darwin_arm64 | ||
- linux_amd64 | ||
- linux_arm64 | ||
- linux_arm_5 | ||
- id: cloudcore-server | ||
main: ./cmd/cloudcore-server | ||
binary: cloudcore | ||
ldflags: | ||
- -s -w -X github.com/clarkmcc/cloudcore/pkg/version.Version={{.Version}} -X github.com/clarkmcc/cloudcore/pkg/version.Hash={{.Commit}} | ||
env: | ||
- CGO_ENABLED=0 | ||
targets: | ||
- darwin_amd64 | ||
- darwin_arm64 | ||
- linux_amd64 | ||
- linux_arm64 | ||
- linux_arm_5 | ||
nfpms: | ||
- id: cloudcored-linux | ||
package_name: cloudcored | ||
builds: | ||
- cloudcored | ||
vendor: cloudcore | ||
homepage: https://cloudcore.clarkmccauley.com/ | ||
maintainer: Clark McCauley | ||
license: MIT | ||
formats: | ||
- deb | ||
scripts: | ||
preinstall: scripts/linux/preinstall.sh | ||
# todo: Setup systemd service | ||
# postinstall: scripts/linux/postinstall.sh | ||
# preremove: scripts/linux/preremove.sh | ||
# postremove: scripts/linux/postremove.sh | ||
# Whether to enable the size reporting or not. | ||
|
||
dockers: | ||
# Server | ||
- id: cloudcore-server | ||
image_templates: | ||
- ghcr.io/clarkmcc/cloudcore | ||
ids: | ||
- cloudcore-server | ||
goos: linux | ||
goarch: amd64 | ||
dockerfile: ./cmd/cloudcore-server/Dockerfile | ||
|
||
report_sizes: true |
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,5 @@ | ||
FROM scratch | ||
|
||
COPY cloudcore /cloudcore | ||
|
||
ENTRYPOINT ["cloudcore"] |
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
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,42 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"go.uber.org/fx" | ||
"go.uber.org/zap" | ||
"gopkg.in/tomb.v2" | ||
"os" | ||
"os/signal" | ||
) | ||
|
||
// signaller accepts a global tomb that doesn't need to be provided via | ||
// the fx framework and returns a fx.Provider function that takes control | ||
// of the tomb and connects it to a signal handler. When the signal is | ||
// received, then the tomb is killed. | ||
// | ||
// Why a global tomb rather than a tomb scoped to the fx app you may ask? | ||
// Because we need the final shutdown step of the application to be waiting | ||
// for the tomb to die, and this needs to happen outside the fx app. | ||
func signaller(t *tomb.Tomb) func(logger *zap.Logger) (*tomb.Tomb, context.Context) { | ||
return func(logger *zap.Logger) (*tomb.Tomb, context.Context) { | ||
ctx, _ := signal.NotifyContext(t.Context(context.Background()), os.Interrupt) | ||
go func() { | ||
<-ctx.Done() | ||
logger.Info("received shutdown signal") | ||
t.Kill(ctx.Err()) | ||
}() | ||
return t, ctx | ||
} | ||
} | ||
|
||
// shutdowner is a fx.Invoke-compatible function that triggers an fx shutdown | ||
// when we see that the tomb is dying. | ||
func shutdowner(s fx.Shutdowner, tomb *tomb.Tomb, logger *zap.Logger) { | ||
go func() { | ||
<-tomb.Dying() | ||
err := s.Shutdown(fx.ExitCode(0)) | ||
if err != nil { | ||
logger.Error("shutting down", zap.Error(err)) | ||
} | ||
}() | ||
} |
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
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
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
Oops, something went wrong.