Skip to content

Commit

Permalink
ci: adds k3s runner and k3s binary in release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtcoder17 committed Oct 4, 2024
1 parent f16e417 commit 878c536
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,98 @@ jobs:
# builds_iac_job: ${{ matrix.name == 'iac-job' }}
# builds_aws_spot_node_terminator: ${{ matrix.name == 'aws-spot-node-terminator' }}
# builds_gcp_spot_node_terminator: ${{ matrix.name == 'gcp-spot-node-terminator' }}

build-k3s-runner-and-binary:
runs-on: ubuntu-latest
env:
k3s_version: "v1.30.5+k3s1"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: setup nix (with cachix)
uses: kloudlite/actions/setup-nix-cachix@v1
with:
flake_lock: ${{ inputs.working_directory }}/flake.lock
nix_develop_arguments: ${{ inputs.working_directory }}#default

cachix_cache_name: ${{ secrets.CACHIX_CACHE_NAME }}
cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: build k3s runner
shell: bash
working-directory: ./${{ env.SUBMODULE }}/cmd/k3s-runner
run: |+
GOARCH=amd64 task build
GOARCH=arm64 task build
- name: download supported k3s binary
shell: bash
run: |+
curl -L0 "https://github.com/k3s-io/k3s/releases/download/$k3s_version/k3s" > bin/k3s-amd64
curl -L0 "https://github.com/k3s-io/k3s/releases/download/$k3s_version/k3s-arm64" > bin/k3s-arm64
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: k3s
path: bin/*

releasing-binaries:
runs-on: ubuntu-latest
needs: build-k3s-runner-and-binary
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/binaries
pattern: "k3s-*"

- name: flattening all the artifacts
shell: bash
run: |+
ls -R ${{ github.workspace }}/binaries
mkdir -p ${{ github.workspace }}/upload/binaries
shopt -s globstar
file ./** | grep 'executable,' | awk -F: '{print $1}' | xargs -I {} cp {} ${{ github.workspace }}/upload/binaries
shopt -u globstar
- uses: nxtcoder17/actions/generate-image-tag@v1
id: tag_name

- name: running for master branch
if: startsWith(github.ref, 'refs/heads/master')
run: |+
echo "IMAGE_TAG=nightly" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
- name: ensure github release exists
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |+
set +e
gh release list -R ${{ github.repository }} | grep -i $IMAGE_TAG
exit_code=$?
if [ $exit_code -ne 0 ]; then
gh release create $IMAGE_TAG -R ${{ github.repository }} --generate-notes --prerelease --draft=false
fi
- name: upload to github release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |+
extra_args=""
if [ "$IMAGE_TAG" = "nightly" ]; then
extra_args="--clobber"
fi
gh release upload $IMAGE_TAG -R ${{github.repository}} $extra_args ${{github.workspace}}/upload/binaries/*
- name: mark release as latest
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |+
gh release edit $IMAGE_TAG -R ${{ github.repository }} --latest

0 comments on commit 878c536

Please sign in to comment.