diff --git a/.config/goreleaser.yml b/.config/goreleaser.yml new file mode 100644 index 0000000..98647a5 --- /dev/null +++ b/.config/goreleaser.yml @@ -0,0 +1,56 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + main: ./cmd/qmlimportsort + binary: qmlimportsort + +archives: + - formats: [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 + formats: [zip] + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +release: + footer: >- + + --- + + Released by [GoReleaser](https://github.com/goreleaser/goreleaser). diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e88bfde..ddb7473 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,10 +6,10 @@ name: CI on: push: - branches: [main] - tags: ['v*'] - pull_request: - branches: [main] + branches: + - '**' + tags: + - 'v*' jobs: test: @@ -44,59 +44,20 @@ jobs: contents: write steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v5 + with: + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v6 with: go-version: '1.24' - - name: Get version - id: version - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - - - name: Build Linux AMD64 - run: | - GOOS=linux GOARCH=amd64 go build -o qmlimportsort ./cmd/qmlimportsort - zip qmlimportsort-${{ steps.version.outputs.VERSION }}-linux-amd64.zip qmlimportsort - rm qmlimportsort - - - name: Build Linux ARM64 - run: | - GOOS=linux GOARCH=arm64 go build -o qmlimportsort ./cmd/qmlimportsort - zip qmlimportsort-${{ steps.version.outputs.VERSION }}-linux-arm64.zip qmlimportsort - rm qmlimportsort - - - name: Build macOS AMD64 - run: | - GOOS=darwin GOARCH=amd64 go build -o qmlimportsort ./cmd/qmlimportsort - zip qmlimportsort-${{ steps.version.outputs.VERSION }}-darwin-amd64.zip qmlimportsort - rm qmlimportsort - - - name: Build macOS ARM64 - run: | - GOOS=darwin GOARCH=arm64 go build -o qmlimportsort ./cmd/qmlimportsort - zip qmlimportsort-${{ steps.version.outputs.VERSION }}-darwin-arm64.zip qmlimportsort - rm qmlimportsort - - - name: Build Windows AMD64 - run: | - GOOS=windows GOARCH=amd64 go build -o qmlimportsort.exe . - zip qmlimportsort-${{ steps.version.outputs.VERSION }}-windows-amd64.zip qmlimportsort.exe - rm qmlimportsort.exe - - - name: Create Release - uses: softprops/action-gh-release@v2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 with: - files: | - qmlimportsort-${{ steps.version.outputs.VERSION }}-linux-amd64.zip - qmlimportsort-${{ steps.version.outputs.VERSION }}-linux-arm64.zip - qmlimportsort-${{ steps.version.outputs.VERSION }}-darwin-amd64.zip - qmlimportsort-${{ steps.version.outputs.VERSION }}-darwin-arm64.zip - qmlimportsort-${{ steps.version.outputs.VERSION }}-windows-amd64.zip - draft: true - prerelease: false - generate_release_notes: true + version: "~> v2" + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 0179240..16a33ba 100644 --- a/.gitignore +++ b/.gitignore @@ -190,4 +190,7 @@ tags # End of https://www.toptal.com/developers/gitignore/api/goland+all,vim,intellij+all,visualstudiocode +# Added by goreleaser init: +dist/ + qmlimportsort diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index babe6ab..4390b9a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,7 @@ repos: hooks: - id: yamlfmt name: "format yml" + exclude: ^.config/ args: - "-formatter" - "line_ending=lf"