mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-21 15:56:24 +00:00
fix build system
This commit is contained in:
parent
087b293c39
commit
2c5266c9a0
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@ -10,12 +10,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
- name: Docker Labels
|
- name: Docker Labels
|
||||||
id: meta
|
id: meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v2
|
uses: crazy-max/ghaction-docker-meta@v4
|
||||||
with:
|
with:
|
||||||
images: cupcakearmy/autorestic
|
images: cupcakearmy/autorestic
|
||||||
tags: |
|
tags: |
|
||||||
@ -23,12 +23,12 @@ jobs:
|
|||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
@ -40,14 +40,9 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: "^1.16.3"
|
go-version: "^1.20"
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go run build/build.go
|
run: go run build/build.go
|
||||||
|
|
||||||
- name: Sign
|
|
||||||
uses: tristan-weil/ghaction-checksum-sign-artifact@v1.0.1
|
|
||||||
with:
|
|
||||||
path: dist/*
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"crypto/sha1"
|
||||||
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@ -31,12 +35,37 @@ type buildOptions struct {
|
|||||||
Target, Arch, Version string
|
Target, Arch, Version string
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(options buildOptions, wg *sync.WaitGroup) {
|
const (
|
||||||
fmt.Printf("Building %s %s\n", options.Target, options.Arch)
|
CHECKSUM_MD5 = "MD5SUMS"
|
||||||
|
CHECKSUM_SHA_1 = "SHA1SUMS"
|
||||||
|
CHECKSUM_SHA_256 = "SHA256SUMS"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Checksums struct {
|
||||||
|
filename, md5, sha1, sha256 string
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeChecksums(checksums *[]Checksums) {
|
||||||
|
FILE_MD5, _ := os.OpenFile(path.Join(DIR, CHECKSUM_MD5), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||||
|
defer FILE_MD5.Close()
|
||||||
|
FILE_SHA1, _ := os.OpenFile(path.Join(DIR, CHECKSUM_SHA_1), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||||
|
defer FILE_SHA1.Close()
|
||||||
|
FILE_SHA256, _ := os.OpenFile(path.Join(DIR, CHECKSUM_SHA_256), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||||
|
defer FILE_SHA256.Close()
|
||||||
|
|
||||||
|
for _, checksum := range *checksums {
|
||||||
|
fmt.Fprintf(FILE_MD5, "%s %s\n", checksum.md5, checksum.filename)
|
||||||
|
fmt.Fprintf(FILE_SHA1, "%s %s\n", checksum.sha1, checksum.filename)
|
||||||
|
fmt.Fprintf(FILE_SHA256, "%s %s\n", checksum.sha256, checksum.filename)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func build(options buildOptions, wg *sync.WaitGroup, checksums *[]Checksums) {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
|
fmt.Printf("Building: %s %s\n", options.Target, options.Arch)
|
||||||
out := fmt.Sprintf("autorestic_%s_%s_%s", options.Version, options.Target, options.Arch)
|
out := fmt.Sprintf("autorestic_%s_%s_%s", options.Version, options.Target, options.Arch)
|
||||||
out = path.Join(DIR, out)
|
out = path.Join(DIR, out)
|
||||||
out, _ = filepath.Abs(out)
|
|
||||||
fmt.Println(out)
|
|
||||||
|
|
||||||
// Build
|
// Build
|
||||||
{
|
{
|
||||||
@ -65,22 +94,39 @@ func build(options buildOptions, wg *sync.WaitGroup) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Done()
|
|
||||||
|
// Checksum
|
||||||
|
{
|
||||||
|
file := out + ".bz2"
|
||||||
|
content, _ := ioutil.ReadFile(file)
|
||||||
|
*checksums = append(*checksums, Checksums{
|
||||||
|
filename: path.Base(file),
|
||||||
|
md5: fmt.Sprintf("%x", md5.Sum(content)),
|
||||||
|
sha1: fmt.Sprintf("%x", sha1.Sum(content)),
|
||||||
|
sha256: fmt.Sprintf("%x", sha256.Sum256(content)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Built: %s\n", path.Base(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
os.RemoveAll(DIR)
|
os.RemoveAll(DIR)
|
||||||
v := internal.VERSION
|
v := internal.VERSION
|
||||||
|
checksums := []Checksums{}
|
||||||
|
|
||||||
|
// Build async
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for target, archs := range targets {
|
for target, archs := range targets {
|
||||||
for _, arch := range archs {
|
for _, arch := range archs {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
build(buildOptions{
|
go build(buildOptions{
|
||||||
Target: target,
|
Target: target,
|
||||||
Arch: arch,
|
Arch: arch,
|
||||||
Version: v,
|
Version: v,
|
||||||
}, &wg)
|
}, &wg, &checksums)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
writeChecksums(&checksums)
|
||||||
}
|
}
|
||||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module github.com/cupcakearmy/autorestic
|
module github.com/cupcakearmy/autorestic
|
||||||
|
|
||||||
go 1.18
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/blang/semver/v4 v4.0.0
|
github.com/blang/semver/v4 v4.0.0
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "1.7.6"
|
const VERSION = "1.7.7"
|
||||||
|
|
||||||
type OptionMap map[string][]interface{}
|
type OptionMap map[string][]interface{}
|
||||||
type Options map[string]OptionMap
|
type Options map[string]OptionMap
|
||||||
|
Loading…
Reference in New Issue
Block a user