mirror of
https://github.com/pushbits/server.git
synced 2025-05-06 13:46:27 +02:00
Publish using GoReleaser
This commit is contained in:
parent
3a483526b6
commit
86971a5691
5 changed files with 71 additions and 14 deletions
53
.github/workflows/publish.yml
vendored
53
.github/workflows/publish.yml
vendored
|
@ -5,17 +5,10 @@ on:
|
||||||
tags:
|
tags:
|
||||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: ghcr.io
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test_build_publish:
|
test:
|
||||||
name: Test, build, and publish
|
name: Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -36,6 +29,24 @@ jobs:
|
||||||
source $(poetry env info --path)/bin/activate
|
source $(poetry env info --path)/bin/activate
|
||||||
make test
|
make test
|
||||||
|
|
||||||
|
publish_docker_image:
|
||||||
|
name: Publish Docker image
|
||||||
|
needs: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Export GOBIN
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.16
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
@ -69,3 +80,27 @@ jobs:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
publish_github_release:
|
||||||
|
name: Publish GitHub Release
|
||||||
|
needs: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Export GOBIN
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.16
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v2
|
||||||
|
with:
|
||||||
|
distribution: goreleaser
|
||||||
|
version: latest
|
||||||
|
args: release --rm-dist
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: Main
|
name: Test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -32,3 +32,6 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
source $(poetry env info --path)/bin/activate
|
source $(poetry env info --path)/bin/activate
|
||||||
make test
|
make test
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: make build
|
19
.goreleaser.yml
Normal file
19
.goreleaser.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
builds:
|
||||||
|
- id: pushbits
|
||||||
|
main: ./cmd/pushbits
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X main.version=v{{.Version}}
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
algorithm: sha256
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- id: pushbits
|
||||||
|
builds:
|
||||||
|
- pushbits
|
||||||
|
format: tar.gz
|
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ SEMGREP_MODFILE := $(TESTS_DIR)/semgrep-rules/go.mod
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
mkdir -p $(OUT_DIR)
|
mkdir -p $(OUT_DIR)
|
||||||
go build -ldflags="-w -s -X main.Version=$(VERSION)" -o $(OUT_DIR)/pushbits ./cmd/pushbits
|
go build -ldflags="-w -s -X main.version=$(VERSION)" -o $(OUT_DIR)/pushbits ./cmd/pushbits
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/pushbits/server/internal/runner"
|
"github.com/pushbits/server/internal/runner"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version string
|
var version string
|
||||||
|
|
||||||
func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
|
func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
|
||||||
c := make(chan os.Signal)
|
c := make(chan os.Signal)
|
||||||
|
@ -44,10 +44,10 @@ func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
|
||||||
|
|
||||||
// @securityDefinitions.basic BasicAuth
|
// @securityDefinitions.basic BasicAuth
|
||||||
func main() {
|
func main() {
|
||||||
if len(Version) == 0 {
|
if len(version) == 0 {
|
||||||
log.Panic("Version not set")
|
log.Panic("Version not set")
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Starting PushBits %s", Version)
|
log.Printf("Starting PushBits %s", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := configuration.Get()
|
c := configuration.Get()
|
||||||
|
|
Loading…
Add table
Reference in a new issue