1+ name : ghctl CD Pipeline
2+
3+ on :
4+ push :
5+ branches : [master]
6+
7+ jobs :
8+ deploy :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Checkout Repository
12+ uses : actions/checkout@v4
13+ - uses : actions/setup-go@v5
14+ with :
15+ go-version : " 1.25.6"
16+ - name : Build for multiple architectures
17+ run : |
18+ GOOS=darwin GOARCH=amd64 go build -o artifacts/${{ vars.PROJECT_REPONAME }}_darwin_amd64
19+ GOOS=linux GOARCH=amd64 go build -o artifacts/${{ vars.PROJECT_REPONAME }}_linux_amd64
20+ GOOS=windows GOARCH=amd64 go build -o artifacts/${{ vars.PROJECT_REPONAME }}_windows_amd64.exe
21+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -o artifacts/${{ vars.PROJECT_REPONAME }}_alpinelinux_amd64
22+ - name : Build yq for alpine image
23+ run : |
24+ git clone git@github.com:mikefarah/yq.git
25+ cd yq
26+ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a
27+ - name : Publish to DockerHub
28+ run : |
29+ cp artifacts/${{ vars.PROJECT_REPONAME }}_alpinelinux_amd64 ./${{ vars.PROJECT_REPONAME }}
30+ VERSION=$(./artifacts/${{ vars.PROJECT_REPONAME }}_linux_amd64 --version)
31+ echo "${{ secrets.DOCKER_PASS }}" | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
32+ IMAGE_NAME=${{ secrets.DOCKER_USER }}/${{ vars.PROJECT_REPONAME }}
33+ docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:$VERSION .
34+ docker push $IMAGE_NAME:$VERSION
35+ docker push $IMAGE_NAME:latest
36+ - name : List artifacts
37+ run : ls -lah artifacts/
38+ - name : Publish Release on GitHub
39+ run : |
40+ go get github.com/tcnksm/ghr
41+ VERSION=v$(./artifacts/${{ vars.PROJECT_REPONAME }}_linux_amd64 --version)
42+ ghr -t ${{ secrets.GITHUB_TOKEN }} -u ${{ vars.PROJECT_USERNAME }} -r ${{ vars.PROJECT_REPONAME }} -c ${{ github.sha }} -n ${VERSION} -delete ${VERSION} ./artifacts/
0 commit comments