diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..90ec23f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +indent_size = 2 +indent_style = space +insert_final_newline = true +tab_width = 4 +trim_trailing_whitespace = true + +[*.go] +indent_style = tab + +[Makefile] +indent_style = tab diff --git a/.github/delete-prereleases.yml b/.github/delete-prereleases.yml new file mode 100644 index 0000000..207628d --- /dev/null +++ b/.github/delete-prereleases.yml @@ -0,0 +1,17 @@ +--- +name: Delete pre-releases + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: dev-drprasad/delete-older-releases@v0.3.2 + with: + delete_prerelease_only: true + delete_tags: true + keep_latest: 0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7876bf6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +--- + name: CI + + on: + push: + branches: + - "**" + pull_request: + branches: + - "**" + workflow_dispatch: + + jobs: + preflight: + runs-on: ubuntu-latest + outputs: + go_version: ${{ steps.get_go_version.outputs.go_version }} + steps: + - uses: actions/checkout@v3 + + - id: get_go_version + name: Get Golang version + run: | + set -euo pipefail + + go_version=$(sed -n 3p ${GITHUB_WORKSPACE}/go.mod | cut -d " " -f2) + echo "Golang version: ${go_version}" + echo "go_version=$go_version" >> "$GITHUB_OUTPUT" + + build: + needs: preflight + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ needs.preflight.outputs.go_version }} + + - name: Build + run: make build + + - name: Test + run: make test diff --git a/.github/workflows/delete-prereleases.yml b/.github/workflows/delete-prereleases.yml new file mode 100644 index 0000000..207628d --- /dev/null +++ b/.github/workflows/delete-prereleases.yml @@ -0,0 +1,17 @@ +--- +name: Delete pre-releases + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: dev-drprasad/delete-older-releases@v0.3.2 + with: + delete_prerelease_only: true + delete_tags: true + keep_latest: 0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cf13b50 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release + +on: + push: + tags: + - "**" + +permissions: + contents: write + +jobs: + preflight: + runs-on: ubuntu-latest + outputs: + go_version: ${{ steps.get_go_version.outputs.go_version }} + steps: + - uses: actions/checkout@v3 + + - id: get_go_version + name: Get Golang version + run: | + set -euo pipefail + + go_version=$(sed -n 3p ${GITHUB_WORKSPACE}/go.mod | cut -d " " -f2) + echo "Golang version: ${go_version}" + echo "go_version=$go_version" >> "$GITHUB_OUTPUT" + + release: + needs: preflight + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: git fetch --force --tags + + - uses: actions/setup-go@v4 + with: + go-version: ${{ needs.preflight.outputs.go_version }} + + - uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..261efb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# ide +.env +.vscode + +# go +/vertag + +# other +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..eb6dcc5 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,45 @@ +# 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: + - main: ./cmd/vertag/vertag.go + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip +checksum: + name_template: "checksums.txt" +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +# The lines beneath this are called `modelines`. See `:help modeline` +# 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