diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml deleted file mode 100644 index cd30b139..00000000 --- a/.github/workflows/bump-version.yml +++ /dev/null @@ -1,38 +0,0 @@ -# This workflow is manually triggered. -name: Bump version -permissions: - contents: write - -on: - workflow_dispatch: - inputs: - version: - description: 'Version number (x.x.x)' - required: true - -jobs: - bump-version: - runs-on: ubuntu-latest - steps: - - name: Check out source - uses: actions/checkout@v6 - - - name: Setup Git - run: | - git config user.name 'GitHub Actions' - git config user.email 'actions@github.com' - - - name: Bump version - run: | - VERSION=${{ github.event.inputs.version }} - hack/update-version.sh "${VERSION}" - git add cmd/gmailctl/cmd/version.go - git commit -m "Bump version to ${VERSION}" - git tag -a "v${VERSION}" -m "Release version ${VERSION}." - - hack/update-version.sh "${VERSION}-dev" - git add cmd/gmailctl/cmd/version.go - git commit -m "Bump version to ${VERSION}-dev" - - - name: Push latest version - run: git push origin master --follow-tags diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..06be711e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version number (x.x.x)' + required: true + type: string + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 + with: + go-version-file: go.mod + + - name: Setup Git + run: | + git config user.name 'GitHub Actions' + git config user.email 'actions@github.com' + + - name: Create and push tag + run: | + VERSION="${{ inputs.version }}" + git tag -a "v${VERSION}" -m "Release version ${VERSION}" + git push origin "v${VERSION}" + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@e24998b8b67b290c2fa8b7c14fcfa7de2c5c9b8c # v7.1.0 + with: + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..977a6888 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,39 @@ +version: 2 + +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm64 + main: ./cmd/gmailctl + ldflags: + - -s -w -X github.com/mbrt/gmailctl/cmd/gmailctl/cmd.version={{.Version}} + +archives: + - formats: + - tar.gz + name_template: "gmailctl_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + format_overrides: + - goos: windows + formats: + - zip + +checksum: + name_template: checksums.txt + algorithm: sha256 + +release: + draft: false + prerelease: auto diff --git a/README.md b/README.md index 00d40a8f..ab84a175 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,13 @@ This project then exists to provide to your Gmail filters: ## Install +Pre-built binaries for Linux, macOS, and Windows (amd64 and arm64) are available +on the [GitHub releases page](https://github.com/mbrt/gmailctl/releases). Download +the archive for your platform, extract it, and place the `gmailctl` binary somewhere +in your `$PATH`. + +Alternatively, if you have Go installed, you can build and install from source: + gmailctl is written in Go and requires a recent version (see [go.mod](go.mod)). Make sure to setup your [`$GOPATH`](https://golang.org/doc/code.html#GOPATH) correctly and include its `bin` subdirectory in your `$PATH`. @@ -75,7 +82,7 @@ correctly and include its `bin` subdirectory in your `$PATH`. go install github.com/mbrt/gmailctl/cmd/gmailctl@latest ``` -Alternatively, if you're on macOS, you can install easily via Homebrew or Macports: +If you're on macOS, you can also install via Homebrew or Macports: ``` # Install with Homebrew diff --git a/cmd/gmailctl/cmd/version.go b/cmd/gmailctl/cmd/version.go index 1bbe9874..6749810e 100644 --- a/cmd/gmailctl/cmd/version.go +++ b/cmd/gmailctl/cmd/version.go @@ -1,4 +1,3 @@ package cmd -// DO NOT EDIT manually! Generated by hack/update-version.sh -var version = "0.11.0-dev" +var version = "dev" diff --git a/hack/update-version.sh b/hack/update-version.sh deleted file mode 100755 index d475f6f3..00000000 --- a/hack/update-version.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Update the version number in cmd/gmailctl/cmd/version.go - -set -e - -VERSION=${1:?} - -[[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]] || { - echo "Invalid version format: ${VERSION}" - exit 1 -} - -sed -i "s/version = \".*\"/version = \"${VERSION}\"/" cmd/gmailctl/cmd/version.go