-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add goreleaser and github actions
- Loading branch information
Showing
7 changed files
with
271 additions
and
6 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,60 @@ | ||
--- | ||
name: publish github release artifacts with goreleaser | ||
on: | ||
push: | ||
tags: '*' | ||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
environment: release | ||
steps: | ||
- name: setup-go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.20' | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to the GitHub Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Log in to the Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
run: go mod download | ||
|
||
- name: goreleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
DOCKER_GITHUB_REPO: ghcr.io/${{ github.actor }}/${{ github.repository }} | ||
DOCKER_HUB_REPO: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/certjunkie | ||
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,97 @@ | ||
# Terraform Provider testing workflow. | ||
name: Tests | ||
|
||
# This GitHub action runs your tests for each pull request and push. | ||
# Optionally, you can turn it on using a schedule for regular testing. | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
- 'README.md' | ||
push: | ||
paths-ignore: | ||
- 'README.md' | ||
|
||
# Testing only needs permissions to read the repository contents. | ||
permissions: | ||
contents: read | ||
|
||
# Default values to simplify job configurations below. | ||
env: | ||
# Go language version to use for building. This value should also be updated | ||
# in the release workflow if changed. | ||
GO_VERSION: '1.20' | ||
|
||
jobs: | ||
# Build and test | ||
test: | ||
name: Test golang | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
run: go mod download | ||
|
||
- run: go build -v . | ||
- run: go test -v -cover ./... | ||
|
||
|
||
# test goreleaser build | ||
goreleaser-snapshot: | ||
name: Test goreleaser | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
run: go mod download | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: goreleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
version: latest | ||
args: release --snapshot --clean | ||
env: | ||
DOCKER_GITHUB_REPO: local | ||
DOCKER_HUB_REPO: local |
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,3 +1,6 @@ | ||
dist/ | ||
certjunkie | ||
|
||
.idea/ | ||
|
||
# Binaries for programs and plugins | ||
|
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,86 @@ | ||
before: | ||
hooks: | ||
- go mod download | ||
env: | ||
- CGO_ENABLED=0 | ||
- GOPROXY=https://proxy.golang.org | ||
project_name: certjunkie | ||
|
||
builds: | ||
- id: builds | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
|
||
main: main.go | ||
|
||
dockers: | ||
- image_templates: | ||
- "{{ .Env.DOCKER_HUB_REPO }}:{{ .Version }}-amd64" | ||
- "{{ .Env.DOCKER_GITHUB_REPO }}:{{ .Version }}-amd64" | ||
use: buildx | ||
dockerfile: Dockerfile.goreleaser | ||
build_flag_templates: | ||
- "--platform=linux/amd64" | ||
|
||
- image_templates: | ||
- "{{ .Env.DOCKER_HUB_REPO }}:{{ .Version }}-arm64" | ||
- "{{ .Env.DOCKER_GITHUB_REPO }}:{{ .Version }}-arm64" | ||
use: buildx | ||
goarch: arm64 | ||
dockerfile: Dockerfile.goreleaser | ||
build_flag_templates: | ||
- "--platform=linux/arm64" | ||
|
||
docker_manifests: | ||
# docker hub | ||
- name_template: "{{ .Env.DOCKER_HUB_REPO }}:latest" | ||
image_templates: | ||
- "{{ .Env.DOCKER_HUB_REPO }}:{{ .Version }}-amd64" | ||
- "{{ .Env.DOCKER_HUB_REPO }}:{{ .Version }}-arm64" | ||
- name_template: "{{ .Env.DOCKER_HUB_REPO }}:{{ .Version }}" | ||
image_templates: | ||
- "{{ .Env.DOCKER_HUB_REPO }}:{{ .Version }}-amd64" | ||
- "{{ .Env.DOCKER_HUB_REPO }}:{{ .Version }}-arm64" | ||
|
||
# github container | ||
- name_template: "{{ .Env.DOCKER_GITHUB_REPO }}:latest" | ||
image_templates: | ||
- "{{ .Env.DOCKER_GITHUB_REPO }}:{{ .Version }}-amd64" | ||
- "{{ .Env.DOCKER_GITHUB_REPO }}:{{ .Version }}-arm64" | ||
- name_template: "{{ .Env.DOCKER_GITHUB_REPO }}:{{ .Version }}" | ||
image_templates: | ||
- "{{ .Env.DOCKER_GITHUB_REPO }}:{{ .Version }}-amd64" | ||
- "{{ .Env.DOCKER_GITHUB_REPO }}:{{ .Version }}-arm64" | ||
|
||
checksum: | ||
name_template: "checksums.txt" | ||
|
||
changelog: | ||
sort: asc | ||
use: github | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
- '^chore' | ||
- Merge pull request | ||
- Merge remote-tracking branch | ||
- Merge branch | ||
- go mod tidy | ||
groups: | ||
- title: 'New Features' | ||
regexp: "^.*feat[(\\w)]*:+.*$" | ||
order: 0 | ||
- title: 'Bug fixes' | ||
regexp: "^.*fix[(\\w)]*:+.*$" | ||
order: 10 | ||
- title: Other work | ||
order: 999 | ||
release: | ||
# If you want to manually examine the release before its live, uncomment this line: | ||
# draft: true | ||
footer: | | ||
**Full Changelog**: https://github.com/project0/certjunkie/compare/{{ .PreviousTag }}...{{ .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
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,11 @@ | ||
FROM golang:1.20-alpine as builder | ||
|
||
FROM scratch | ||
|
||
WORKDIR /root/ | ||
COPY --from=builder /etc/ssl/certs /etc/ssl/certs | ||
|
||
COPY certjunkie /certjunkie | ||
ENTRYPOINT ["/certjunkie"] | ||
|
||
CMD [ "server" ] |
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