diff --git a/.dockerignore b/.dockerignore index d4ed635..02deb67 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,5 @@ LICENSE.md README.md docs -.github \ No newline at end of file +.github +.goreleaser.yaml \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 72b43fb..d024d46 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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 \ No newline at end of file + run: go build -v ./... \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ab98868 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: goreleaser + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3.2.0 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "stable" + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4.4.0 + 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 \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..0dde443 --- /dev/null +++ b/.goreleaser.yaml @@ -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.*' \ No newline at end of file