From fdfa2989ff9573fd1f89ef528940458bb08fb65b Mon Sep 17 00:00:00 2001 From: Zhao Xiaojie Date: Sun, 1 Mar 2020 18:45:02 +0800 Subject: [PATCH] Add goreleaser config file (#347) * Add goreleaser config file * Change the name template * Change the name template of nfpms * Add goos freedsd and windows * Add linux and darwin for the go os * Add sign for the binary files * Remove sign for the binary files * Skip changelog * Change the snapshot * Use goreleaser to build jcli * Checks if goreleaser configuration is valid * Fix the wrong cmd of gorelease --- .github/workflows/backup.yaml | 22 ++++++-- .github/workflows/pull-request.yaml | 6 +++ .goreleaser.yml | 84 +++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.github/workflows/backup.yaml b/.github/workflows/backup.yaml index b966d94..d405179 100644 --- a/.github/workflows/backup.yaml +++ b/.github/workflows/backup.yaml @@ -18,14 +18,30 @@ jobs: - name: Build run: | export PATH=$PATH:${PWD}/bin:$GOPATH/bin:/home/runner/go/bin - make clean go-bindata-download-linux tools init release + git fetch --prune --unshallow + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v1 + with: + version: latest + args: release --rm-dist --snapshot - name: Publish Release run: | git clone https://github.com/jenkins-zh/jcli-repo + cp release/checksums.txt jcli-repo + cp release/jcli-darwin-386.tar.gz jcli-repo + cp release/jcli-darwin-amd64.tar.gz jcli-repo cp release/jcli-darwin-amd64.tar.gz jcli-repo + cp release/jcli-freebsd-386.tar.gz jcli-repo + cp release/jcli-freebsd-amd64.tar.gz jcli-repo + cp release/jcli-linux-32bit.deb jcli-repo + cp release/jcli-linux-32bit.rpm jcli-repo + cp release/jcli-linux-386.tar.gz jcli-repo + cp release/jcli-linux-64bit.deb jcli-repo + cp release/jcli-linux-64bit.rpm jcli-repo cp release/jcli-linux-amd64.tar.gz jcli-repo - cp release/jcli-windows-386.tar.gz jcli-repo - cd jcli-repo && git config --local user.email "rick@jenkins-zh.cn" && git config --local user.name "rick" && git add . && git commit -m 'Auto commit by bot' && git push https://linuxsuren:${{ secrets.GITHUB_SECRETS }}@github.com/jenkins-zh/jcli-repo.git + cp release/jcli-windows-386.zip jcli-repo + cp release/jcli-windows-amd64.zip jcli-repo + cd jcli-repo && git config --local user.email "361981269@qq.com" && git config --local user.name "rick" && git add . && git commit -m 'Auto commit by rick bot' && git push https://linuxsuren:${{ secrets.GITHUB_SECRETS }}@github.com/jenkins-zh/jcli-repo.git - name: backup uses: jenkins-zh/git-backup-actions@v0.0.3 diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 6988fa4..34fc36c 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -20,6 +20,12 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v1 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v1 + with: + version: latest + args: check + - name: Build run: | export PATH=$PATH:${PWD}/bin:$GOPATH/bin:/home/runner/go/bin diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..f846139 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,84 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +project_name: jcli +before: + hooks: + - make gen-data +builds: +- env: + - CGO_ENABLED=0 + binary: jcli + goos: + - freebsd + - windows + - linux + - darwin + ldflags: + - -X github.com/jenkins-zh/jenkins-cli/app.version={{.Version}} + - -X github.com/jenkins-zh/jenkins-cli/app.commit={{.ShortCommit}} +dist: release +archives: +- name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}" + replacements: + darwin: darwin + linux: linux + windows: windows + 386: 386 + amd64: amd64 + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next-{{.ShortCommit}}" +changelog: + skip: true + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +brews: + - + name: jcli + github: + owner: jenkins-zh + name: homebrew-jcli + folder: Formula + homepage: "https://github.com/jenkins-zh/jenkins-cli" + description: Jenkins CLI allows you manage your Jenkins as an easy way + test: | + version_output = shell_output("#{bin}/jcli version") + assert_match version.to_s, version_output + install: | + bin.install name + + # Install bash completion + output = Utils.popen_read("#{bin}/jcli completion") + (bash_completion/"jcli").write output + + # Install zsh completion + output = Utils.popen_read("#{bin}/jcli completion --type zsh") + (zsh_completion/"_jcli").write output + + prefix.install_metafiles +nfpms: + - file_name_template: "{{ .Binary }}-{{.Os}}-{{.Arch}}" + homepage: https://github.com/jenkins-zh/jenkins-cli + description: Jenkins CLI allows you manage your Jenkins as an easy way + maintainer: rick + license: MIT + vendor: Jenkins + formats: + - deb + - rpm + bindir: /usr/bin + replacements: + amd64: 64bit + 386: 32bit + arm: ARM + arm64: ARM64 + darwin: macOS + linux: linux + windows: windows \ No newline at end of file -- GitLab