Skip to content

Commit

Permalink
Update CI/CD pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
paololazzari committed Nov 10, 2023
1 parent 6e3c789 commit 68e9c29
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
LICENSE.md
README.md
docs
.github
.github
.goreleaser.yaml
23 changes: 1 addition & 22 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,4 @@ jobs:
go-version: 1.19

- name: Build
run: go build -v ./...

ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build image
run: |
# Login dockerhub
pwd="${{ secrets.dockerhub }}"
docker login -u="plazzari" -p="${pwd}"
# Get version
VERSION=$(awk -F '[="]' '/^const version/ {print $3}' cmd/core.go)
# Build docker images
docker build . --tag "plazzari/play:${VERSION}"
docker tag "plazzari/play:${VERSION}" plazzari/play:latest
# Deploy docker images
docker push "plazzari/play:${VERSION}"
docker push plazzari/play:latest
run: go build -v ./...
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: goreleaser

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "stable"

- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and release docker image
run: |
# Login dockerhub
pwd="${{ secrets.dockerhub }}"
docker login -u="plazzari" -p="${pwd}"
# Get version
VERSION=$(awk -F '[="]' '/^const version/ {print $3}' cmd/core.go)
# Build docker images
docker build . --tag "plazzari/play:${VERSION}"
docker tag "plazzari/play:${VERSION}" plazzari/play:latest
# Deploy docker images
docker push "plazzari/play:${VERSION}"
docker push plazzari/play:latest
27 changes: 27 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- format: zip
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '.*Docker.*'
- '.*README.*'
- '.*[Dd]ocumentation.*'
- '.*[Pp]ipelines.*'
- '.*gitignore.*'
- '.*dockerignore.*'

0 comments on commit 68e9c29

Please sign in to comment.