From a0f564a49a3312be6c09832651f64c755b3ab803 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Wed, 10 Jan 2024 19:41:02 +0800 Subject: [PATCH 1/4] build and publish winget with goreleaser (cherry picked from commit a507e85dcef4d43e60a826b2703851772ee5f326) --- .github/workflows/release-build.yml | 32 +++++---- .gitignore | 2 + .goreleaser.yaml | 103 ++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 89d42e1ba..9d9fcf00a 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 - - - name: Build + go-version: "1.21" + + - 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..ca4604942 --- /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: GoPlus + 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.GoPlus + 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: goplus + name: winget-pkgs + branch: master From 29fab0c2381c4e319583f6ff0fd078de13c0b8e0 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Wed, 10 Jan 2024 20:00:38 +0800 Subject: [PATCH 2/4] clear whitespace (cherry picked from commit 8c1c69283a9f79dab2a515fde1c6c17ab707a847) --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 9d9fcf00a..6f0a55ab5 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -34,7 +34,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.21" - + - name: Install goreleaser run: | go install github.com/goreleaser/goreleaser@latest From e873f5590999eda4ccbfb75e8897696ccbb0433b Mon Sep 17 00:00:00 2001 From: Li Jie Date: Wed, 10 Jan 2024 22:30:11 +0800 Subject: [PATCH 3/4] fix winget-pkgs PR owner (cherry picked from commit 1800e5cacd95af1021ccce089102d47afa7f581e) --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index ca4604942..0db8cf6dd 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -98,6 +98,6 @@ winget: enabled: true draft: false base: - owner: goplus + owner: microsoft name: winget-pkgs branch: master From bc2dd28d9e53f6fc7d3c85cb961fb738252f0d9d Mon Sep 17 00:00:00 2001 From: Li Jie Date: Wed, 10 Jan 2024 23:11:26 +0800 Subject: [PATCH 4/4] rename winget pkg name (cherry picked from commit 85507f830a1cfb73b43b3e4b65bef83b54c2f50c) --- .goreleaser.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0db8cf6dd..10495b0d8 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -68,12 +68,12 @@ changelog: - "^test:" winget: - - name: GoPlus + - name: gop homepage: "https://goplus.org/" - publisher: GoPlus + publisher: goplus publisher_url: https://github.com/goplus/gop publisher_support_url: "https://github.com/goplus/gop/issues/new" - package_identifier: GoPlus.GoPlus + package_identifier: goplus.gop short_description: The Go+ Programming Language description: | The Go+ programming language is designed for engineering, STEM education, and data science.