-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable go builds and image pushes on release
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
- Loading branch information
Showing
8 changed files
with
185 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,111 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-20.04 | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
hash: ${{ steps.set-hash.outputs.hash }} | ||
changed_files: ${{ steps.changed-files.outputs.all_changed_files }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Populate list of changed images | ||
id: set-matrix-changed-images | ||
run: | | ||
changed_images=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E 'images/.+/Dockerfile' | awk -F/ '{print $2}' | jq -R -c -s 'split("\n")[:-1]') | ||
echo "matrix_changed_images={\"image\":$changed_images}" >> $GITHUB_OUTPUT | ||
- name: Calculate a hash for images/ | ||
id: set-hash | ||
run: echo "hash=${{ hashFiles('images/**') }}" >> $GITHUB_OUTPUT | ||
|
||
publish_images: | ||
needs: prepare | ||
runs-on: ubuntu-20.04 | ||
if: needs.prepare.outputs.matrix_changed_images != 'null' | ||
strategy: | ||
matrix: ${{fromJson(needs.prepare.outputs.matrix_changed_images)}} | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Quay | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.QUAY_USER }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
registry: quay.io | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Cache Buildx Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ needs.prepare.outputs.hash }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Build ${{ matrix.image }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
platforms: | ||
- linux/amd64 | ||
- linux/arm64 | ||
- linux/arm/v7 | ||
push: true | ||
load: true | ||
tags: | ||
- ${{ matrix.image }}:latest | ||
- quay.io/k0sproject/footloose-${{ matrix.image }}:latest | ||
context: images/${{ matrix.image }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
publish_binaries: | ||
name: release | ||
needs: prepare | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
# Ugly hack to get the tag name | ||
# github.ref gives the full reference like refs.tags.v0.0.1-beta1 | ||
- name: Branch name | ||
id: branch_name | ||
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Build binaries | ||
id: build_bins | ||
env: | ||
TAG_NAME: ${{ steps.branch_name.outputs.TAG_NAME }} | ||
run: make build-all | ||
|
||
- name: Create release and upload binaries | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: | | ||
bin/footloose-* | ||
bin/sha256sums.txt | ||
body_path: bin/checksums.md | ||
tag_name: ${{ steps.branch_name.outputs.TAG_NAME }} | ||
name: ${{ steps.branch_name.outputs.TAG_NAME }} | ||
draft: true # So we can manually edit before publishing | ||
prerelease: ${{ contains(steps.branch_name.outputs.TAG_NAME, '-') }} # v0.1.2-beta1, 1.2.3-rc1 |
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
cluster-key | ||
cluster-key.pub | ||
footloose | ||
/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
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 was deleted.
Oops, something went wrong.
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,14 @@ | ||
package version | ||
|
||
import ( | ||
"github.com/carlmjohnson/versioninfo" | ||
) | ||
|
||
var ( | ||
// Version of the product, is set during the build | ||
Version = versioninfo.Version | ||
// GitCommit is set during the build | ||
GitCommit = versioninfo.Revision | ||
// Environment of the product, is set during the build | ||
Environment = "development" | ||
) |