-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from italia/feat/goreleaser-5
GoReleaser to handle versioning and releasing
- Loading branch information
Showing
7 changed files
with
127 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.15 | ||
id: go | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Unshallow | ||
run: git fetch --prune --unshallow | ||
- | ||
name: Docker Login | ||
if: success() && startsWith(github.ref, 'refs/tags/v') | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Make sure to check the documentation at http://goreleaser.com | ||
before: | ||
hooks: | ||
- go mod download | ||
builds: | ||
- | ||
id: publiccode-validator | ||
binary: publiccode-validator | ||
main: ./src | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} -X main.date={{.Date}} | ||
env: | ||
- CGO_ENABLED=0 | ||
# https://github.com/italia/publiccode-parser-go/issues/50 | ||
ignore: | ||
- goos: darwin | ||
goarch: 386 | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
dockers: | ||
- | ||
goos: linux | ||
goarch: amd64 | ||
binaries: | ||
- publiccode-validator | ||
builds: | ||
- publiccode-validator | ||
skip_push: false | ||
dockerfile: Dockerfile.goreleaser | ||
image_templates: | ||
- "italia/publiccode-validator:latest" | ||
- "italia/publiccode-validator:{{ .Tag }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
FROM golang:1.13.1 | ||
# Accept the Go version for the image to be set as a build argument. | ||
ARG GO_VERSION=1.15-alpine | ||
|
||
FROM golang:${GO_VERSION} | ||
|
||
ENV BIN /usr/local/bin/publiccode-validator | ||
|
||
WORKDIR /go/src | ||
|
||
WORKDIR /go/src/pc-web-validator | ||
COPY ./src/ . | ||
COPY .git/ . | ||
|
||
RUN apk add git | ||
|
||
RUN go get -d | ||
|
||
RUN go get -d -v ./... | ||
RUN go install -v ./... | ||
RUN go build -o main | ||
RUN go build -ldflags \ | ||
"-X main.version=$(git describe --abbrev=0 --tags) -X main.date=$(date --iso-8601=second)" \ | ||
-o $BIN \ | ||
&& chmod +x $BIN | ||
|
||
CMD ["./main"] | ||
CMD ["sh","-c","${BIN}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM alpine | ||
|
||
COPY publiccode-validator / | ||
|
||
# Run the compiled binary. | ||
CMD ["/publiccode-validator"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters