Skip to content

Commit

Permalink
Merge pull request #1803 from goplus/main
Browse files Browse the repository at this point in the history
patch
  • Loading branch information
xushiwei authored Mar 9, 2024
2 parents 0a2da22 + 1ca6e23 commit 7367305
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 64 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/check_goreleaser_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import subprocess
import yaml

files = [f for f in os.listdir('.') if not f.startswith(
".") and f not in ["VERSION"]]
files.sort()
# filter out the files that are ignored by git
files = [f for f in files if subprocess.call(
["git", "ls-files", "--error-unmatch", f],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) == 0]

gorel = yaml.load(open(".goreleaser.yaml", "r"), Loader=yaml.FullLoader)
scfiles = [f["source"] for f in gorel["snapcrafts"][0]["extra_files"]]
scfiles.sort()

failed = False

if files != scfiles:
failed = True
print("Files in snapcraft are different from the ones in the repo")
print("Update .goreleaser.yaml in the snapcraft section:")
for f in files:
print(f" - source: \"{f}\"")
print(f" destination: \"{f}\"")

nfpms_files = [f["src"]
for f in gorel["nfpms"][0]["contents"] if f.get("type") != "symlink"]
nfpms_files.sort()

if files != nfpms_files:
failed = True
print("Files in nfpms are different from the ones in the repo")
print("Update .goreleaser.yaml in the nfpms section:")
for f in files:
print(f" - src: \"{f}\"")
print(f" dst: \"/usr/lib/{{{{ .ProjectName }}}}/{f}\"")

if failed:
exit(1)

print(".goreleaser checks passed")
9 changes: 9 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ on:
branches: [ main ]

jobs:
Check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check goreleaser files
run: |
pip install --no-input pyyaml
python .github/workflows/check_goreleaser_config.py
Test:
strategy:
matrix:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check goreleaser files
run: |
pip install --no-input pyyaml
python .github/workflows/check_goreleaser_config.py
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v2
Expand Down Expand Up @@ -64,7 +69,7 @@ jobs:
- name: Upload deb/rpm to Fury.io
if: env.IS_PRERELEASE != 'true'
run: |
for file in dist/*.{deb,rpm}
for file in .dist/*.{deb,rpm}
do
echo "Uploading $file to Fury.io"
CODE=`curl --write-out '%{http_code}' --output /dev/null -sS -F package=@$file https://[email protected]/$GITHUB_REPOSITORY_OWNER/`
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ bin/
go-num/
_todo*.go

dist/
.dist/
175 changes: 113 additions & 62 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 1
dist: ".dist"

before:
hooks:
Expand Down Expand Up @@ -146,42 +147,66 @@ nfpms:
bindir: /usr/lib/{{ .ProjectName }}
contents:
# source folder
- src: LICENSE
dst: /usr/lib/{{ .ProjectName }}/LICENSE
- src: "LICENSE"
dst: "/usr/lib/{{ .ProjectName }}/LICENSE"
- src: "Makefile"
dst: "/usr/lib/{{ .ProjectName }}/Makefile"
- src: "README.md"
dst: /usr/lib/{{ .ProjectName }}/README.md
dst: "/usr/lib/{{ .ProjectName }}/README.md"
- src: "_gendeps.go"
dst: "/usr/lib/{{ .ProjectName }}/_gendeps.go"
- src: "all.bash"
dst: "/usr/lib/{{ .ProjectName }}/all.bash"
- src: "all.bat"
dst: "/usr/lib/{{ .ProjectName }}/all.bat"
- src: "ast"
dst: "/usr/lib/{{ .ProjectName }}/ast"
- src: "build_install_run.go"
dst: "/usr/lib/{{ .ProjectName }}/build_install_run.go"
- src: "builtin"
dst: "/usr/lib/{{ .ProjectName }}/builtin"
- src: "cl"
dst: "/usr/lib/{{ .ProjectName }}/cl"
- src: "cmd"
dst: "/usr/lib/{{ .ProjectName }}/cmd"
- src: "doc"
dst: "/usr/lib/{{ .ProjectName }}/doc"
- src: "env"
dst: "/usr/lib/{{ .ProjectName }}/env"
- src: "format"
dst: "/usr/lib/{{ .ProjectName }}/format"
- src: "gengo.go"
dst: "/usr/lib/{{ .ProjectName }}/gengo.go"
- src: "go.mod"
dst: /usr/lib/{{ .ProjectName }}/go.mod
dst: "/usr/lib/{{ .ProjectName }}/go.mod"
- src: "go.sum"
dst: /usr/lib/{{ .ProjectName }}/go.sum
- src: "*.go"
dst: /usr/lib/{{ .ProjectName }}/
- src: ast
dst: /usr/lib/{{ .ProjectName }}/ast
- src: builtin
dst: /usr/lib/{{ .ProjectName }}/builtin
- src: cl
dst: /usr/lib/{{ .ProjectName }}/cl
- src: cmd
dst: /usr/lib/{{ .ProjectName }}/cmd
- src: doc
dst: /usr/lib/{{ .ProjectName }}/doc
- src: env
dst: /usr/lib/{{ .ProjectName }}/env
- src: format
dst: /usr/lib/{{ .ProjectName }}/format
- src: parser
dst: /usr/lib/{{ .ProjectName }}/parser
- src: printer
dst: /usr/lib/{{ .ProjectName }}/parser
- src: scanner
dst: /usr/lib/{{ .ProjectName }}/scanner
- src: token
dst: /usr/lib/{{ .ProjectName }}/token
- src: watcher
dst: /usr/lib/{{ .ProjectName }}/watcher
dst: "/usr/lib/{{ .ProjectName }}/go.sum"
- src: "imp.go"
dst: "/usr/lib/{{ .ProjectName }}/imp.go"
- src: "load.go"
dst: "/usr/lib/{{ .ProjectName }}/load.go"
- src: "make.bash"
dst: "/usr/lib/{{ .ProjectName }}/make.bash"
- src: "make.bat"
dst: "/usr/lib/{{ .ProjectName }}/make.bat"
- src: "outline.go"
dst: "/usr/lib/{{ .ProjectName }}/outline.go"
- src: "parser"
dst: "/usr/lib/{{ .ProjectName }}/parser"
- src: "printer"
dst: "/usr/lib/{{ .ProjectName }}/printer"
- src: "scanner"
dst: "/usr/lib/{{ .ProjectName }}/scanner"
- src: "test"
dst: "/usr/lib/{{ .ProjectName }}/test"
- src: "testdata"
dst: "/usr/lib/{{ .ProjectName }}/testdata"
- src: "tidy.go"
dst: "/usr/lib/{{ .ProjectName }}/tidy.go"
- src: "token"
dst: "/usr/lib/{{ .ProjectName }}/token"
- src: "x"
dst: /usr/lib/{{ .ProjectName }}/x
dst: "/usr/lib/{{ .ProjectName }}/x"
# symlinks to binaries
- src: "/usr/lib/{{ .ProjectName }}/bin/gop"
dst: /usr/bin/gop
Expand Down Expand Up @@ -211,40 +236,66 @@ snapcrafts:
{{- if .Arm }}v{{ .Arm }}{{ end }}
extra_files:
# source folder
- source: LICENSE
destination: LICENSE
- source: "LICENSE"
destination: "LICENSE"
- source: "Makefile"
destination: "Makefile"
- source: "README.md"
destination: README.md
destination: "README.md"
- source: "_gendeps.go"
destination: "_gendeps.go"
- source: "all.bash"
destination: "all.bash"
- source: "all.bat"
destination: "all.bat"
- source: "ast"
destination: "ast"
- source: "build_install_run.go"
destination: "build_install_run.go"
- source: "builtin"
destination: "builtin"
- source: "cl"
destination: "cl"
- source: "cmd"
destination: "cmd"
- source: "doc"
destination: "doc"
- source: "env"
destination: "env"
- source: "format"
destination: "format"
- source: "gengo.go"
destination: "gengo.go"
- source: "go.mod"
destination: go.mod
destination: "go.mod"
- source: "go.sum"
destination: go.sum
- source: ast
destination: ast
- source: builtin
destination: builtin
- source: cl
destination: cl
- source: cmd
destination: cmd
- source: doc
destination: doc
- source: env
destination: env
- source: format
destination: format
- source: parser
destination: parser
- source: printer
destination: parser
- source: scanner
destination: scanner
- source: token
destination: token
- source: watcher
destination: watcher
destination: "go.sum"
- source: "imp.go"
destination: "imp.go"
- source: "load.go"
destination: "load.go"
- source: "make.bash"
destination: "make.bash"
- source: "make.bat"
destination: "make.bat"
- source: "outline.go"
destination: "outline.go"
- source: "parser"
destination: "parser"
- source: "printer"
destination: "printer"
- source: "scanner"
destination: "scanner"
- source: "test"
destination: "test"
- source: "testdata"
destination: "testdata"
- source: "tidy.go"
destination: "tidy.go"
- source: "token"
destination: "token"
- source: "x"
destination: x
destination: "x"
apps:
gop:
command: "gop"
Expand Down

0 comments on commit 7367305

Please sign in to comment.