From dcfa851ae6f9aebbcd7ab6ccb4e5d569a0388494 Mon Sep 17 00:00:00 2001 From: Mateusz Szostok Date: Sat, 12 Feb 2022 20:34:59 +0100 Subject: [PATCH] Update goreleaser, add release GitHub Action --- .github/workflows/release.yml | 43 ++++++++++++++++ .gitignore | 3 +- .goreleaser.yml | 95 ++++++++++++++++++++--------------- 3 files changed, 100 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..677bdcf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + goreleaser: + name: Run GoReleaser + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Install upx 3.96 + run: | + wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz + tar -xf upx-3.96-amd64_linux.tar.xz + mv ./upx-3.96-amd64_linux/upx /usr/local/bin/upx + upx -V + - name: Docker Login + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index bc692d9..210df0f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ scripts/ codeowners-validator dist/ tmp/ -coverage.txt \ No newline at end of file +bin/ +coverage.txt diff --git a/.goreleaser.yml b/.goreleaser.yml index 3d134eb..2571790 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,49 +1,64 @@ builds: -- env: - - CGO_ENABLED=0 - hooks: - # Install upx first, https://github.com/upx/upx/releases - post: ./hack/compress.sh - goos: - - linux - - darwin - - windows - goarch: - - amd64 - - 386 - ldflags: - - -s -w -X github.com/mszostok/codeowners-validator/pkg/version.version={{.Version}} -X github.com/mszostok/codeowners-validator/pkg/version.commit={{.ShortCommit}} -X github.com/mszostok/codeowners-validator/pkg/version.buildDate={{.Date}} - # List of combinations of GOOS + GOARCH + GOARM to ignore. - # Default is empty. - ignore: - - goos: darwin - goarch: 386 -archive: - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 - format_overrides: - - goos: windows - format: zip -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ .Tag }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' + - id: codeowners-validator + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - "386" + - amd64 + - arm64 + ldflags: + - -s -w -X github.com/mszostok/codeowners-validator/pkg/version.version={{.Version}} -X github.com/mszostok/codeowners-validator/pkg/version.commit={{.ShortCommit}} -X github.com/mszostok/codeowners-validator/pkg/version.buildDate={{.Date}} + # List of combinations of GOOS + GOARCH + GOARM to ignore. + # Default is empty. + ignore: + - goos: windows # due to upx error: CantPackException: can't pack new-exe + goarch: arm64 + hooks: + # Install upx first, https://github.com/upx/upx/releases + post: upx -9 "{{ .Path }}" + +archives: + - format: binary + name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}" dockers: - dockerfile: Dockerfile - binaries: + ids: - codeowners-validator image_templates: + - "ghcr.io/mszostok/codeowners-validator:stable" + - "ghcr.io/mszostok/codeowners-validator:{{ .Tag }}" + - "ghcr.io/mszostok/codeowners-validator:v{{ .Major }}.{{ .Minor }}" + - "ghcr.io/mszostok/codeowners-validator:v{{ .Major }}" - "mszostok/codeowners-validator:latest" - "mszostok/codeowners-validator:{{ .Tag }}" - "mszostok/codeowners-validator:v{{ .Major }}.{{ .Minor }}" + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ .Tag }}-next" + +changelog: + use: github + filters: + exclude: + - '^docs:' + - '^test:' + +dist: bin + +release: + # If set to true, will not auto-publish the release. + # Default is false. + draft: true + # Repo in which the release will be created. + # Default is extracted from the origin remote URL or empty if its private hosted. + github: + owner: mszostok + name: codeowners-validator