diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..420be9a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 9e5d3c3..1d700ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -/vendor +vendor +dist diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..0d2ec2d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,45 @@ +project_name: skpr-api +version: 2 + +builds: + - id: skpr-apiserver-mock + main: ./cmd/apiserver-mock + binary: skpr-apiserver-mock + ldflags: + - -extldflags '-static' + env: + - CGO_ENABLED=0 + goos: [ linux ] + goarch: [ amd64, arm64 ] + +dockers: + - dockerfile: dockerfiles/apiserver-mock/Dockerfile + image_templates: + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-amd64" + - "ghcr.io/skpr/api:latest-amd64" + build_flag_templates: + - "--pull" + - "--platform=linux/amd64" + use: buildx + - dockerfile: dockerfiles/apiserver-mock/Dockerfile + image_templates: + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-arm64" + - "ghcr.io/skpr/api:latest-arm64" + build_flag_templates: + - "--pull" + - "--platform=linux/arm64" + use: buildx + goarch: arm64 + +docker_manifests: + - name_template: "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}" + image_templates: + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-amd64" + - "ghcr.io/skpr/api:{{ .Major }}.{{ .Minor }}-arm64" + - name_template: "ghcr.io/skpr/api:latest" + image_templates: + - "ghcr.io/skpr/api:latest-amd64" + - "ghcr.io/skpr/api:latest-arm64" + +release: + draft: true diff --git a/Makefile b/Makefile index 7e8ea64..a0c7b24 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ build: rm -fR $(DIR) mkdir -p $(DIR) # Building image. - docker build -t $(IMAGE) . + docker build -t $(IMAGE) dockerfiles/grpc-go # Building package. docker run -it -w $(PWD) -v $(PWD):$(PWD) $(IMAGE) /bin/bash -c 'protoc --go_out=./pb --go_opt=paths=source_relative --go-grpc_out=./pb --go-grpc_opt=paths=source_relative *.proto' diff --git a/dockerfiles/apiserver-mock/Dockerfile b/dockerfiles/apiserver-mock/Dockerfile new file mode 100644 index 0000000..c46ee45 --- /dev/null +++ b/dockerfiles/apiserver-mock/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:latest + +COPY skpr-apiserver-mock /usr/local/bin/ + +ENTRYPOINT ["/usr/local/bin/skpr-apiserver-mock"] diff --git a/Dockerfile b/dockerfiles/grpc-go/Dockerfile similarity index 100% rename from Dockerfile rename to dockerfiles/grpc-go/Dockerfile