-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: goreleaser release #101
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,65 +5,48 @@ on: | |||||||||||||
tags: | ||||||||||||||
- '*' | ||||||||||||||
|
||||||||||||||
permissions: | ||||||||||||||
contents: write | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to re-add packages permission to publish images
Suggested change
|
||||||||||||||
|
||||||||||||||
jobs: | ||||||||||||||
# use goreleaser to cross-compile go binaries and add them to GitHub release | ||||||||||||||
goreleaser: | ||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||
permissions: | ||||||||||||||
contents: write | ||||||||||||||
env: | ||||||||||||||
DOCKER_CLI_EXPERIMENTAL: "enabled" | ||||||||||||||
REGISTYRY: "ghcr.io" | ||||||||||||||
IMAGE_NAME: "google/addlicense" | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this still has the same "testing in forks issues" if we hardcode the value.
Suggested change
|
||||||||||||||
steps: | ||||||||||||||
- | ||||||||||||||
name: Checkout | ||||||||||||||
- name: Checkout | ||||||||||||||
uses: actions/checkout@v2 | ||||||||||||||
with: | ||||||||||||||
fetch-depth: 0 | ||||||||||||||
- | ||||||||||||||
name: Set up Go | ||||||||||||||
- name: Set up Go | ||||||||||||||
uses: actions/setup-go@v2 | ||||||||||||||
with: | ||||||||||||||
go-version: 1.16 | ||||||||||||||
- | ||||||||||||||
name: Run GoReleaser | ||||||||||||||
uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86 #v2.7.0 | ||||||||||||||
- uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # [email protected] | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we had an existing convention for all of these comments that would be nice to not change... The real reason I care is that I'm trying to get dependabot to add support for updating these comments, and I'd like to keep them in a consistent format.
Suggested change
|
||||||||||||||
- uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 # [email protected] | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
- name: dockerhub-login | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't publish to dockerhub, so don't need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks fixed. |
||||||||||||||
if: startsWith(github.ref, 'refs/tags/v') | ||||||||||||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 # [email protected] | ||||||||||||||
with: | ||||||||||||||
username: ${{ secrets.DOCKER_USERNAME }} | ||||||||||||||
password: ${{ secrets.DOCKER_PASSWORD }} | ||||||||||||||
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dockerhub login is still here, but should be removed.
Suggested change
|
||||||||||||||
- name: ghcr-login | ||||||||||||||
if: startsWith(github.ref, 'refs/tags/v') | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe change the trigger for this workflow to only match "v*" tags, so then we don't need this check here?
Suggested change
|
||||||||||||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 # [email protected] | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
with: | ||||||||||||||
registry: ghcr.io | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
username: ${{ github.actor }} | ||||||||||||||
password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||
- name: Run GoReleaser | ||||||||||||||
uses: goreleaser/goreleaser-action@5df302e5e9e4c66310a6b6493a8865b12c555af2 # [email protected] | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
with: | ||||||||||||||
distribution: goreleaser | ||||||||||||||
version: latest | ||||||||||||||
args: release --rm-dist | ||||||||||||||
env: | ||||||||||||||
REGISTRY: ${{ env.REGISTRY }} | ||||||||||||||
IMAGE: ${{ env.IMAGE_NAME }} | ||||||||||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||
|
||||||||||||||
# build and publish docker image | ||||||||||||||
build-and-push-image: | ||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||
permissions: | ||||||||||||||
contents: read | ||||||||||||||
packages: write | ||||||||||||||
env: | ||||||||||||||
REGISTRY: ghcr.io | ||||||||||||||
IMAGE_NAME: ${{ github.repository }} | ||||||||||||||
|
||||||||||||||
steps: | ||||||||||||||
- name: Checkout repository | ||||||||||||||
uses: actions/checkout@v2 | ||||||||||||||
|
||||||||||||||
- name: Log in to the Container registry | ||||||||||||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 #v1.10.0 | ||||||||||||||
with: | ||||||||||||||
registry: ${{ env.REGISTRY }} | ||||||||||||||
username: ${{ github.actor }} | ||||||||||||||
password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||
|
||||||||||||||
- name: Extract metadata (tags, labels) for Docker | ||||||||||||||
id: meta | ||||||||||||||
uses: docker/metadata-action@8b842e721d38d18bea23b57f4c040e53331f4ca2 #v3.4.1 | ||||||||||||||
with: | ||||||||||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||||||||||||||
|
||||||||||||||
- name: Build and push Docker image | ||||||||||||||
uses: docker/build-push-action@1bc1040caef9e604eb543693ba89b5bf4fc80935 #v2.6.1 | ||||||||||||||
with: | ||||||||||||||
context: . | ||||||||||||||
push: true | ||||||||||||||
tags: ${{ steps.meta.outputs.tags }} | ||||||||||||||
labels: ${{ steps.meta.outputs.labels }} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,16 +1,55 @@ | ||||||
before: | ||||||
hooks: | ||||||
- go mod tidy | ||||||
|
||||||
env: | ||||||
- GO111MODULE=on | ||||||
- CGO_ENABLED=0 | ||||||
|
||||||
builds: | ||||||
- env: | ||||||
- CGO_ENABLED=0 | ||||||
- binary: addlicense | ||||||
goos: | ||||||
- linux | ||||||
- windows | ||||||
- darwin | ||||||
goarch: | ||||||
- amd64 | ||||||
- arm64 | ||||||
dockers: | ||||||
- image_templates: | ||||||
- '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}-amd64' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love having these extra I tried doing multi-architecture builds using the the regular docker actions to build the image, and it's definitely possible to do multi-architecture images without the intermediate tags (the |
||||||
dockerfile: Dockerfile.goreleaser | ||||||
use: buildx | ||||||
build_flag_templates: | ||||||
- "--pull" | ||||||
- "--label=org.opencontainers.image.created={{.Date}}" | ||||||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||||||
- "--label=org.opencontainers.image.version={{.Version}}" | ||||||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||||||
- "--platform=linux/amd64" | ||||||
- image_templates: | ||||||
- '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}-arm64' | ||||||
dockerfile: Dockerfile.goreleaser | ||||||
use: buildx | ||||||
build_flag_templates: | ||||||
- "--pull" | ||||||
- "--label=org.opencontainers.image.created={{.Date}}" | ||||||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||||||
- "--label=org.opencontainers.image.version={{.Version}}" | ||||||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||||||
- "--platform=linux/arm64" | ||||||
goarch: arm64 | ||||||
docker_manifests: | ||||||
- name_template: '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}::{{ .Tag }}' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo, fails to build image
Suggested change
|
||||||
image_templates: | ||||||
- '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}-amd64' | ||||||
- '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}-arm64' | ||||||
- name_template: 'ghcr.io/google/addlicense:latest' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missed one hardcoded image name
Suggested change
|
||||||
image_templates: | ||||||
- '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}-amd64' | ||||||
- '{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}-arm64' | ||||||
archives: | ||||||
- format_overrides: | ||||||
- goos: windows | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# make a bare minimal image | ||
FROM scratch | ||
|
||
WORKDIR /src | ||
|
||
COPY addlicense /app/addlicense | ||
|
||
ENTRYPOINT ["/app/addlicense"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.