-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add a makefile command to assist with multi-arch builds #68
base: main
Are you sure you want to change the base?
Changes from 5 commits
2fb3e93
35127f2
74c44a0
50943f5
bb43a91
bff393b
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
bump-type: | ||
type: choice | ||
description: The position of the version to be bumped. | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
tag_to_move: | ||
type: choice | ||
description: The generic tag to be advanced. | ||
options: | ||
- v1 | ||
jobs: | ||
|
||
test-and-lint: | ||
name: Test and Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Lint | ||
run: make lint | ||
- name: Test | ||
run: make test | ||
|
||
multi-arch-build-and-push: | ||
name: Build Multi Arch Containers | ||
runs-on: ubuntu-latest | ||
needs: [test-and-lint] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
# Add support for more platforms with QEMU (optional) | ||
# https://github.com/docker/setup-qemu-action | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Docker Login | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
default_bump: ${{ github.event.inputs.bump-type }} | ||
Comment on lines
+50
to
+55
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 will select the new version and tag the repo |
||
- name: Build Release Container | ||
env: | ||
VERSION: ${{ steps.tag_version.outputs.new_version }} | ||
run: make buildx | ||
Comment on lines
+58
to
+59
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. Use that new version for the multi-arch build |
||
- name: Move Generic Tag Version | ||
|
||
advance-generic-tag: | ||
runs-on: ubuntu-latest | ||
needs: [multi-arch-build-and-push] | ||
Bwvolleyball marked this conversation as resolved.
Show resolved
Hide resolved
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Git config | ||
run: | | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
- name: Tag new target | ||
run: git tag -f ${{ github.event.inputs.tag_to_move }} ${{ github.event.inputs.target }} | ||
- name: Push new 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. This will advance the |
||
run: git push origin ${{ github.event.inputs.tag_to_move }} --force |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
IMAGE_REPO=ghcr.io/trstringer/manual-approval | ||
|
||
# Great for building a single architecture's image | ||
.PHONY: build | ||
build: | ||
@if [ -z "$$VERSION" ]; then \ | ||
|
@@ -23,3 +24,14 @@ test: | |
.PHONY: lint | ||
lint: | ||
docker run --rm -v $$(pwd):/app -w /app golangci/golangci-lint:v1.46.2 golangci-lint run -v | ||
|
||
# Builds multiple architectures at once. | ||
# Requires docker buildx and QEMU to be configured. | ||
# Because of how docker buildx works, in that it _must_ push when it builds, push is the default of this task. | ||
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'm not sure I understand why a push is required. Why do we want our build command to automatically push the image? 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 is a nuance of how 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. Ultimately, this |
||
.PHONY: buildx | ||
buildx: | ||
@if [ -z "$$VERSION" ]; then \ | ||
echo "VERSION is required"; \ | ||
exit 1; \ | ||
fi | ||
docker buildx build -t $(IMAGE_REPO):$$VERSION --platform linux/amd64,linux/arm64 --push . |
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.
Options to select which part of the version to bump, and the generic tag to move on running this job.