From 3b7cab0e70f6198d7794e05c65231acbed855ae1 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 20 Jan 2024 15:24:42 -0800 Subject: [PATCH] Build updates --- .github/workflows/codetests.yml | 2 +- .github/workflows/release.yml | 55 +++++++++++++++ .gitignore | 3 + .goreleaser.yaml | 115 ++++++++++++++++++++++++++++++++ README.md | 2 +- 5 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/codetests.yml b/.github/workflows/codetests.yml index a9d4977..1171277 100644 --- a/.github/workflows/codetests.yml +++ b/.github/workflows/codetests.yml @@ -20,4 +20,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: 'v1.55' + version: 'v1.54' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2a7fe9e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: build-and-release +on: + push: + branches: + - unstable + - main + tags: + - v* + pull_request: + branches: + - main + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - name: Install RPM tooling + run: sudo apt-get install -y rpm + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }} + - name: "Setup Ruby for packagecloud uploads" + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: "Install packagecloud gem" + run: gem install package_cloud + - uses: actions/setup-go@v5 + with: + go-version: '>=1.20.5' + cache: true + - name: "Create GPG_SIGNING_KEY file" + run: "echo '${{ secrets.GPG_SIGNING_KEY }}' > /tmp/key.gpg" + - uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Use a fine grained PAT with Contents: R/W on golift/homebrew-mugs. + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} + GPG_SIGNING_KEY: /tmp/key.gpg + GPG_SIGNING_KEY_ID: ${{ steps.import_gpg.outputs.keyid }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..11af4aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/xt +/xt.* +/dist/ \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..a8756ad --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,115 @@ +version: 1 + +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: + # notice that we need a separated build for the MacOS binary only: + - env: + - CGO_ENABLED=0 + - CGO_LDFLAGS=-mmacosx-version-min=10.8 + - CGO_CFLAGS=-mmacosx-version-min=10.8 + id: macos + goos: + - darwin + goarch: + - amd64 + - arm64 + ldflags: + - -s -w + - -X "golift.io/version.Version={{.Version}}" + - -X "golift.io/version.BuildDate={{.Date}}" + - -X "golift.io/version.BuildUser={{.Env.USER}}" + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - freebsd + goarch: + - amd64 + - arm + - arm64 + - '386' + ldflags: + - -s -w + - -X "golift.io/version.Version={{.Version}}" + - -X "golift.io/version.BuildDate={{.Date}}" + - -X "golift.io/version.BuildUser={{.Env.USER}}" + ignore: + - goos: windows + goarch: arm + + +archives: + - format: tar.gz + format_overrides: + - goos: windows + format: zip + +nfpms: + - id: xt-packages + vendor: Go Lift + homepage: https://unpackerr.com + maintainer: David Newhall II + description: eXtractor Tool - Recursively decompress archives + license: MIT + formats: + - deb + - rpm + - archlinux + - apk + bindir: /usr/bin + version_metadata: git + section: default + priority: extra + provides: + - xt + # signing + rpm: + signature: + key_file: "{{ .Env.GPG_SIGNING_KEY }}" + deb: + signature: + key_file: "{{ .Env.GPG_SIGNING_KEY }}" + type: origin + +universal_binaries: + - replace: true + +signs: + - id: default + artifacts: all + +brews: + - name: xt + # enable the line below only for testing locally + #skip_upload: true + repository: + owner: golift + name: homebrew-mugs + branch: master + token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" + commit_author: + name: goreleaserbot + email: bot@goreleaser.com + commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" + folder: Formula + homepage: https://unpackerr.com/ + description: "eXtractor Tool - Recursively decompress archives" + license: MIT + url_template: "https://github.com/Unpackerr/xt/releases/download/{{ .Tag }}/{{ .ArtifactName }}" + test: assert_match "xt v#{version}", shell_output("#{bin}/xt -v 2>&1", 2) + install: bin.install "xt" + + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/README.md b/README.md index d66d46c..5aedd07 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# xt +# eXtractor Tool Extract Everything. Decompress entire folders filled with archives.