Skip to content

Commit ae5a83f

Browse files
committed
- [+] add CI/CD to publish to central cloudsmith repo
1 parent abe06ad commit ae5a83f

File tree

2 files changed

+108
-33
lines changed

2 files changed

+108
-33
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
GO111MODULE: off
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
-
18+
name: Set up Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.19
22+
23+
-
24+
name: Install Cloudsmith CLI
25+
run: pip install --upgrade cloudsmith-cli
26+
# Cloudsmith CLI tooling for pushing releases
27+
# See https://help.cloudsmith.io/docs/cli
28+
29+
-
30+
name: Checkout
31+
uses: actions/checkout@v2
32+
with:
33+
fetch-depth: 0
34+
35+
-
36+
name: Tests
37+
run: |
38+
export GOPATH=/home/runner/go
39+
mkdir -vp $GOPATH/src/github.com/$GITHUB_REPOSITORY
40+
rmdir -v $GOPATH/src/github.com/$GITHUB_REPOSITORY
41+
mv -v $GITHUB_WORKSPACE $GOPATH/src/github.com/$GITHUB_REPOSITORY
42+
ln -vs $GOPATH/src/github.com/$GITHUB_REPOSITORY $GITHUB_WORKSPACE
43+
# go mod tidy
44+
go get -v ./...
45+
go build -v
46+
go test -v ./...
47+
48+
-
49+
name: Run GoReleaser
50+
uses: goreleaser/goreleaser-action@v2
51+
if: success() && startsWith(github.ref, 'refs/tags/')
52+
with:
53+
version: latest
54+
args: release --rm-dist
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
# Publish to cloudsmith repo
59+
-
60+
name: Publish package to cloudsmith
61+
if: success() && startsWith(github.ref, 'refs/tags/')
62+
env:
63+
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
64+
run: |
65+
for filepath in dist/*; do
66+
echo "== Analyzing '$filepath' for publishing"
67+
filename=$(basename -- "$filepath")
68+
extension="${filename##*.}"
69+
filename="${filename%.*}"
70+
case "$extension" in
71+
'apk')
72+
echo "Pushing '$filepath' to cloudsmith repo"
73+
cloudsmith push alpine suntong/repo/alpine/any-version $filepath
74+
;;
75+
'deb' | 'rpm')
76+
echo "Pushing '$filepath' to cloudsmith repo"
77+
cloudsmith push $extension suntong/repo/any-distro/any-version $filepath
78+
;;
79+
*)
80+
echo "File .$extension skipped publishing"
81+
echo
82+
;;
83+
esac
84+
done

.goreleaser.yml

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,34 @@
1+
project_name: jsonfiddle
2+
3+
archives:
4+
- format: tar.gz
5+
wrap_in_directory: true
6+
format_overrides:
7+
- goos: windows
8+
format: zip
9+
# remove README and LICENSE
10+
files:
11+
- none*
12+
113
builds:
2-
-
3-
env:
4-
# - CGO_ENABLED=0
14+
- env: [CGO_ENABLED=0]
515
goos:
616
- linux
7-
- darwin
817
- windows
18+
- darwin
919
goarch:
10-
- 386
1120
- amd64
12-
# List of combinations of GOOS + GOARCH + GOARM to ignore.
13-
# Default is empty.
14-
ignore:
15-
- goos: darwin
16-
goarch: 386
17-
- goos: windows
18-
goarch: 386
21+
- arm64
1922

20-
archive:
21-
name_template: '{{ .Binary }}_{{ .Os }}_{{ .Version }}_{{ .Arch }}'
22-
replacements:
23-
# darwin: Darwin
24-
windows: Windows
25-
# linux: Linux
26-
# amd64: x86_64
27-
386: i386
28-
format_overrides:
29-
- goos: windows
30-
format: zip
23+
# Path to main.go file or main package.
24+
# Default is `.`.
3125

32-
fpm:
33-
homepage: https://github.com/go-jsonfile/jsonfiddle
34-
description: JSON Fiddling, to look at the JSON data from different aspects.
35-
maintainer: Tong Sun <suntong@cpan.org>
26+
nfpms:
27+
- maintainer: Tong Sun <suntong@cpan.org>
28+
description: jsonfiddle - Tool to fiddle with json strings
29+
homepage: https://github.com/go-jsonfiddle/jsonfiddle
3630
license: MIT
37-
vendor: suntong
3831
formats:
39-
- deb
40-
# - rpm
41-
dependencies:
42-
- git
43-
32+
- deb
33+
- rpm
34+
- apk

0 commit comments

Comments
 (0)