diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index d17cbcf..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Go -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.18 - - name: Fmt - run: test -z $(go fmt ./...) - - name: Vet - run: go vet ./... - - name: Build - run: go build -v ./... - - name: Test - run: go test -v ./... diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml new file mode 100644 index 0000000..39f04eb --- /dev/null +++ b/.github/workflows/goreleaser.yaml @@ -0,0 +1,34 @@ +name: goreleaser + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --force --tags + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - + name: Set up Go + uses: actions/setup-go@v3 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index b238bdd..d9d7ddb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ *.out # Dependency directories (remove the comment below to include it) -# vendor/ \ No newline at end of file +# vendor/ +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..3d27ed4 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,43 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... +builds: + - id: yj + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + ldflags: "-X main.Version={{ .Version }}" +dockers: + - id: yj + goos: linux + goarch: amd64 + image_templates: + - "sclevine/yj:latest" + - "sclevine/yj:{{ .Version }}" +archives: + - id: yj +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# modelines, feel free to remove those if you don't want/use them: +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/Dockerfile b/Dockerfile index dc45324..ab9c51c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,3 @@ -FROM golang:alpine AS builder -RUN apk update && apk add --no-cache git -WORKDIR /workspace -COPY . . -ARG version="0.0.0" -RUN go build -ldflags "-X main.Version=$version" . FROM scratch -COPY --from=builder /workspace/yj /bin/yj +COPY yj /bin/yj ENTRYPOINT ["/bin/yj"] diff --git a/build.sh b/build.sh index 604a057..162f730 100755 --- a/build.sh +++ b/build.sh @@ -1,19 +1,2 @@ -#!/bin/bash - -set -e - -version=${1:-0.0.0} -out=build-v${version} -cd "$(dirname "${BASH_SOURCE[0]}")" -mkdir -p "$out" - -GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=$version" -o "$out/yj-macos-amd64" . -GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.Version=$version" -o "$out/yj-macos-arm64" . -GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=$version" -o "$out/yj-linux-amd64" . -GOOS=linux GOARCH=arm64 go build -ldflags "-X main.Version=$version" -o "$out/yj-linux-arm64" . -GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-X main.Version=$version" -o "$out/yj-linux-arm-v5" . -GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-X main.Version=$version" -o "$out/yj-linux-arm-v7" . -GOOS=windows GOARCH=amd64 go build -ldflags "-X main.Version=$version" -o "$out/yj.exe" . - -docker build . --build-arg "version=$version" -t "sclevine/yj:$version" -docker tag "sclevine/yj:$version" "sclevine/yj:latest" \ No newline at end of file +go install github.com/goreleaser/goreleaser/v2@latest +goreleaser release --auto-snapshot --rm-dist \ No newline at end of file diff --git a/go.mod b/go.mod index c37f5e8..1b2a4d7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/sclevine/yj/v5 -go 1.21 +go 1.22 require ( github.com/BurntSushi/toml v1.3.2