Skip to content

Bump actions/upload-artifact from 5 to 6 #1868

Bump actions/upload-artifact from 5 to 6

Bump actions/upload-artifact from 5 to 6 #1868

Workflow file for this run

name: For each commit and PR
on:
push:
branches:
- "**"
tags:
- "v**"
pull_request:
env:
REGISTRY: ghcr.io
IMAGE: ghcr.io/${{ github.repository }}
CGO_ENABLED: 0
GO_VERSION: "1.25"
jobs:
validation:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: false
- name: Restore Go cache
uses: actions/cache/restore@v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
# always grab from the restore-keys pattern below,
# like Linux-go-$hash-YYYY-MM-DD as saved by CI
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
- name: Fix no space errors and Fetch Deps
run: |
# fixes "write /run/user/1001/355792648: no space left on device" error
sudo mount -o remount,size=3G /run/user/1001 || true
go get -t ./... && go mod tidy && go mod download
- name: Run all CI checks, linting, tests, etc
run: make ci TEST_ARGS="-count=1"
- name: upload to codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Trim Go cache
if: ${{ github.ref == 'refs/heads/main' }}
shell: bash
# As the go command works, it either creates build cache files or touches
# ones it uses at most once an hour. When it trims the cache, it trims
# files that have not been modified/touched in 5+ days.
# To keep our saved cache lean, trim all files except ones that were just
# created/touched as part of this run.
run: |
find ~/.cache/go-build -type f -mmin +90 -delete
- name: Set Go cache date
shell: bash
run: echo "GO_CACHE_DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV
- name: Save Go cache
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@v5
with:
# Caches both the downloaded modules and the compiled build cache.
path: |
~/go/pkg/mod
~/.cache/go-build
# Save to eg Linux-go-$hash-YYYY-MM-DD to keep the cache fresh
key: "${{ runner.os }}-go-${{ hashFiles('go.mod') }}-${{ env.GO_CACHE_DATE }}"
validate-helm-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: install helm
uses: Azure/setup-helm@v4
with:
version: v3.17.0
- name: Lint and Template Helm chart
run: make helm-lint helm-template
build-binaries:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: tinkerbell
make-target: cross-compile
artifact-name: tinkerbell-binaries
- name: tink-agent
make-target: cross-compile-agent
artifact-name: tink-agent-binaries
- name: tinkerbell-embedded-linux
make-target: checksums-embedded
artifact-name: tinkerbell-embedded-binaries
extra-paths: out/checksums-embedded.txt
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: false
- name: Restore Go cache
uses: actions/cache/restore@v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
# always grab from the restore-keys pattern below,
# like Linux-go-$hash-YYYY-MM-DD as saved by CI
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
- name: Fix no space errors and Fetch Deps
run: |
# fixes "write /run/user/1001/355792648: no space left on device" error
sudo mount -o remount,size=3G /run/user/1001 || true
go get -t ./... && go mod tidy && go mod download
- name: Compile binaries for ${{ matrix.name }}
run: make ${{ matrix.make-target }}
- name: Upload binaries
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact-name }}
path: |
out/${{ matrix.name }}-*
${{ matrix.extra-paths }}
if-no-files-found: error
build-publish-container-images:
runs-on: ubuntu-latest
if: |
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/tags/v')
needs:
- validation
- build-binaries
strategy:
matrix:
include:
- artifact_name: tinkerbell-binaries
image_name: ghcr.io/tinkerbell/tinkerbell
make-target: build-push-image
- artifact_name: tink-agent-binaries
image_name: ghcr.io/tinkerbell/tink-agent
make-target: build-push-image-agent
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download binaries
uses: actions/download-artifact@v6
with:
name: ${{ matrix.artifact_name }}
path: ./out
merge-multiple: true
# Artifact upload doesn't preserve permissions so we need to fix them.
- name: Fix permissions
run: chmod +x out/*
- name: Prepare build environment
run: make prepare-buildx
- name: Build and publish container images
run: make ${{ matrix.make-target }}
env:
IMAGE_NAME: ${{ matrix.image_name }}
IMAGE_NAME_AGENT: ${{ matrix.image_name }}
package-publish-helm-chart:
runs-on: ubuntu-latest
if: |
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/tags/v')
needs:
- validate-helm-chart
- build-publish-container-images
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
# Go is needed to get the VERSION in the Makefile which is used in the Helm packaging
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: false
- name: Restore Go cache
uses: actions/cache/restore@v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
# always grab from the restore-keys pattern below,
# like Linux-go-$hash-YYYY-MM-DD as saved by CI
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: install helm
uses: Azure/setup-helm@v4
with:
version: v3.17.0
- name: Package and publish the Helm chart
run: make helm-publish
release-notes:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs:
- build-publish-container-images
- package-publish-helm-chart
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Download embedded binaries
uses: actions/download-artifact@v6
with:
name: tinkerbell-embedded-binaries
path: ./out
merge-multiple: true
# Artifact upload doesn't preserve permissions so we need to fix them.
- name: Fix permissions
run: chmod +x out/tinkerbell-*
- name: Publish Changelog to GitHub
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifactErrorsFailBuild: true
generateReleaseNotes: true
draft: true
prerelease: true
artifacts: "out/tinkerbell-embedded-linux-*,out/checksums-embedded.txt"