chore: adopt go-releaser for release automation

This commit is contained in:
garethgeorge
2023-12-01 19:41:14 -08:00
parent 9bb478ed32
commit b8636d1e18
9 changed files with 163 additions and 34 deletions
+19
View File
@@ -0,0 +1,19 @@
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
release-type: simple
+25 -14
View File
@@ -3,8 +3,10 @@ name: "tagged-release"
on:
push:
tags:
- "v*"
workflow_dispatch:
- "*"
permissions:
contents: write
jobs:
tagged-release:
@@ -13,6 +15,8 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
@@ -27,16 +31,23 @@ jobs:
- name: Install Deps
run: ./scripts/install-deps.sh
- name: Build
run: ./scripts/build-all.sh
- uses: "marvinpinto/action-automatic-releases@latest"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
LICENSE
resticui-linux-amd64
resticui-linux-arm64
resticui-darwin-amd64
resticui-darwin-arm64
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: release-artifacts
path: dist/*
+1
View File
@@ -1,2 +1,3 @@
resticui
resticui-*
dist
+58
View File
@@ -0,0 +1,58 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 1
before:
hooks:
- go mod tidy
- go generate ./...
- sh -c "ls && cd ./webui && npm i && npm run build"
builds:
- main: .
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
# - windows
goarch:
- amd64
- arm64
hooks:
post: rice append --exec {{ .Path }}
archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
dockers:
- image_templates:
- garethgeorge/resticweb:latest
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
github:
owner: garethgeorge
name: resticweb
+11
View File
@@ -0,0 +1,11 @@
FROM golang:alpine as gobuild
RUN mkdir /tmp-orig
COPY resticweb /resticweb
RUN /resticweb --install-deps=true
FROM scratch
COPY --from=gobuild /root/.local/share/resticui/ /.local/share/resticui/
COPY --from=gobuild /tmp-orig /tmp
ENTRYPOINT ["/resticweb"]
COPY resticweb /resticweb
-10
View File
@@ -46,29 +46,19 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ=
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY=
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 h1:W12Pwm4urIbRdGhMEg2NM9O3TWKjNcxQhs46V0ypf/k=
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4/go.mod h1:5RBcpGRxr25RbDzY5w+dmaqpSEvl8Gwl1x2CICf60ic=
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo=
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4=
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 h1:ZcOkrmX74HbKFYnpPY8Qsw93fC29TbJXspYKaBkSXDQ=
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4/go.mod h1:k2dtGpRrbsSyKcNPKKI5sstZkrNCZwpU/ns96JoHbGg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
+27 -5
View File
@@ -30,11 +30,12 @@ const (
var ErrNotExist = errors.New("operation does not exist")
var (
SystemBucket = []byte("oplog.system") // system stores metadata
OpLogBucket = []byte("oplog.log") // oplog stores the operations themselves
RepoIndexBucket = []byte("oplog.repo_idx") // repo_index tracks IDs of operations affecting a given repo
PlanIndexBucket = []byte("oplog.plan_idx") // plan_index tracks IDs of operations affecting a given plan
SnapshotIndexBucket = []byte("oplog.snapshot_idx") // snapshot_index tracks IDs of operations affecting a given snapshot
SystemBucket = []byte("oplog.system") // system stores metadata
OpLogBucket = []byte("oplog.log") // oplog stores existant operations.
OpLogSoftDeleteBucket = []byte("oplog.log_soft_delete") // oplog_soft_delete stores soft deleted operations
RepoIndexBucket = []byte("oplog.repo_idx") // repo_index tracks IDs of operations affecting a given repo
PlanIndexBucket = []byte("oplog.plan_idx") // plan_index tracks IDs of operations affecting a given plan
SnapshotIndexBucket = []byte("oplog.snapshot_idx") // snapshot_index tracks IDs of operations affecting a given snapshot
)
// OpLog represents a log of operations performed.
@@ -180,6 +181,27 @@ func (o *OpLog) Update(op *v1.Operation) error {
return err
}
func (o *OpLog) Delete(id int64) error {
err := o.db.Update(func(tx *bolt.Tx) error {
val := tx.Bucket(OpLogBucket).Get(serializationutil.Itob(op.Id))
if val == nil {
return ErrNotExist
}
if err := o.deleteOperationHelper(tx, id); err != nil {
return fmt.Errorf("deleting operation %v: %w", op.Id, err)
}
b := tx.Bucket(OpLogSoftDeleteBucket)
if err := b.Put(serializationutil.Itob(id), val); err != nil {
return fmt.Errorf("putting operation %v into soft delete bucket: %w", id, err)
}
return nil
})
return err
}
func (o *OpLog) notifyHelper(eventType EventType, op *v1.Operation) {
o.subscribersMu.RLock()
defer o.subscribersMu.RUnlock()
+7
View File
@@ -84,6 +84,13 @@ func (t *ForgetTask) Run(ctx context.Context) error {
forgetOp.OperationForget.Forget = append(forgetOp.OperationForget.Forget, forgot...)
for _, forgot := range forgot {
t.orchestrator.OpLog.ForEachBySnapshotId(forgot.Id, func(op *v1.Operation) error {
return t.orchestrator.OpLog.Delete(op.Id)
})
}
return nil
}); err != nil {
return err
+15 -5
View File
@@ -3,6 +3,7 @@ package main
import (
"context"
"errors"
"flag"
"net/http"
"os"
"os/signal"
@@ -23,11 +24,25 @@ import (
"go.uber.org/zap/zapcore"
)
var (
installOnly = flag.Bool("install-deps", false, "Install resticui and exit")
)
func main() {
flag.Parse()
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
go onterm(cancel)
resticPath, err := resticinstaller.FindOrInstallResticBinary()
if err != nil {
zap.S().Fatalf("Error finding or installing restic: %v", err)
}
if *installOnly {
return
}
configStore := createConfigProvider()
cfg, err := configStore.Get()
@@ -58,11 +73,6 @@ func main() {
}
defer oplog.Close()
resticPath, err := resticinstaller.FindOrInstallResticBinary()
if err != nil {
zap.S().Fatalf("Error finding or installing restic: %v", err)
}
orchestrator, err := orchestrator.NewOrchestrator(resticPath, cfg, oplog)
if err != nil {
zap.S().Fatalf("Error creating orchestrator: %v", err)