diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 89d42e1ba..6f0a55ab5 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -3,7 +3,7 @@ name: Release Build on: push: tags: - - "v*.*.*" + - "v*" jobs: build: @@ -18,21 +18,29 @@ jobs: echo Current tag: $tag_name git checkout $tag_name echo "TAG_NAME=${tag_name}" >> $GITHUB_ENV + + - name: Check VERSION consistency + run: | + tag=$(git describe --tags --dirty) + version=$(cat VERSION) + if [ "$tag" != "$version" ]; then + echo "VERSION file is not consistent with tag name" + echo "VERSION: $version" + echo "TAG: $tag" + exit 1 + fi - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: "1.21" - - name: Build + - name: Install goreleaser run: | - make dist + go install github.com/goreleaser/goreleaser@latest - name: Release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ env.TAG_NAME }} - file: ./build-dir/gop-*.zip - file_glob: true - prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WINGET_PKGS_PRIVATE_KEY: ${{ secrets.WINGET_PKGS_PRIVATE_KEY }} + run: goreleaser release -p 4 diff --git a/.gitignore b/.gitignore index 18f4ec7e3..4619940eb 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ cmd/qfmt/qfmt bin/ go-num/ _todo*.go + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..10495b0d8 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,103 @@ +# 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: 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: + - id: gop + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + main: ./cmd/gop + binary: bin/gop + ldflags: + - -X github.com/goplus/gop/env.buildVersion=v{{.Version}} + - -X github.com/goplus/gop/env.buildDate={{.Date}} + - id: gopfmt + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + main: ./cmd/gopfmt + binary: bin/gopfmt + ldflags: + - -X github.com/goplus/gop/env.buildVersion=v{{.Version}} + - -X github.com/goplus/gop/env.buildDate={{.Date}} + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_v{{.Version}}_ + {{- 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 + files: + - LICENSE + - "*.mod" + - "*.sum" + - "*.md" + - "**/*.go" + - "**/*.md" + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +winget: + - name: gop + homepage: "https://goplus.org/" + publisher: goplus + publisher_url: https://github.com/goplus/gop + publisher_support_url: "https://github.com/goplus/gop/issues/new" + package_identifier: goplus.gop + short_description: The Go+ Programming Language + description: | + The Go+ programming language is designed for engineering, STEM education, and data science. + - For engineering: working in the simplest language that can be mastered by children. + - For STEM education: studying an engineering language that can be used for work in the future. + - For data science: communicating with engineers in the same language. + license: Apache-2.0 + skip_upload: false + release_notes: "{{.Changelog}}" + release_notes_url: "https://github.com/goplus/gop/releases/tag/v{{.Version}}" + dependencies: + - package_identifier: GoLang.Go + minimum_version: 1.18.0 + repository: + owner: goplus + name: winget-pkgs + branch: "{{.ProjectName}}-v{{.Version}}" + git: + url: "git@github.com:goplus/winget-pkgs.git" + private_key: "{{ .Env.WINGET_PKGS_PRIVATE_KEY }}" + pull_request: + enabled: true + draft: false + base: + owner: microsoft + name: winget-pkgs + branch: master