mirror of
https://github.com/pushbits/server.git
synced 2025-04-28 09:46:51 +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:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
test_build_publish:
|
||||
name: Test, build, and publish
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
@ -36,6 +29,24 @@ jobs:
|
|||
source $(poetry env info --path)/bin/activate
|
||||
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
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
|
@ -69,3 +80,27 @@ jobs:
|
|||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
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:
|
||||
push:
|
||||
|
@ -32,3 +32,6 @@ jobs:
|
|||
run: |
|
||||
source $(poetry env info --path)/bin/activate
|
||||
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
|
||||
build:
|
||||
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
|
||||
clean:
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/pushbits/server/internal/runner"
|
||||
)
|
||||
|
||||
var Version string
|
||||
var version string
|
||||
|
||||
func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
|
||||
c := make(chan os.Signal)
|
||||
|
@ -44,10 +44,10 @@ func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
|
|||
|
||||
// @securityDefinitions.basic BasicAuth
|
||||
func main() {
|
||||
if len(Version) == 0 {
|
||||
if len(version) == 0 {
|
||||
log.Panic("Version not set")
|
||||
} else {
|
||||
log.Printf("Starting PushBits %s", Version)
|
||||
log.Printf("Starting PushBits %s", version)
|
||||
}
|
||||
|
||||
c := configuration.Get()
|
||||
|
|
Loading…
Add table
Reference in a new issue