chore: bump shellhub version to v0.16.2 #2094
Workflow file for this run
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
name: Build Agent | |
on: | |
push: | |
branches: [ master ] | |
tags: | |
- v* | |
paths: | |
- 'agent/**' | |
- '.github/workflows/build-agent.yml' | |
pull_request: | |
branches: [ master ] | |
paths: | |
- 'agent/**' | |
- '.github/workflows/build-agent.yml' | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
dockerfile: [amd64, arm32v6, arm32v7, arm64v8, i386] | |
include: | |
# includes a new variable of npm with a value of 2 | |
# for the matrix leg matching the os and version | |
- dockerfile: amd64 | |
arch: amd64 | |
- dockerfile: arm32v6 | |
arch: arm/6 | |
- dockerfile: arm32v7 | |
arch: arm/7 | |
- dockerfile: arm64v8 | |
arch: arm64/8 | |
- dockerfile: i386 | |
arch: i386 | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v4 | |
- name: login to docker hub | |
if: "github.event_name != 'pull_request'" | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set github reference env | |
run: echo RELEASE_VERSION=${GITHUB_REF#refs/*/} >> $GITHUB_ENV | |
- name: Set docker build option env | |
if: "github.event_name != 'pull_request'" | |
run: echo "BUILD_OPTION=--provenance=false --push" >> $GITHUB_ENV | |
- name: build image | |
if: "!contains(github.ref, 'refs/tags/v')" | |
run: | | |
docker buildx build ${{ env.BUILD_OPTION }} -f agent/Dockerfile.${{ matrix.dockerfile }} \ | |
--tag shellhubio/agent:${{ github.sha }}-${{ matrix.dockerfile }} \ | |
--platform linux/${{ matrix.arch }} . | |
- name: build image from github tag | |
if: "contains(github.ref, 'refs/tags/v')" | |
run: | | |
docker buildx build ${{ env.BUILD_OPTION }} -f agent/Dockerfile.${{ matrix.dockerfile }} \ | |
--tag shellhubio/agent:${{ env.RELEASE_VERSION }}-${{ matrix.dockerfile }} \ | |
--build-arg SHELLHUB_VERSION=${{ env.RELEASE_VERSION }} \ | |
--platform linux/${{ matrix.arch }} . | |
- name: export rootfs | |
if: "contains(github.ref, 'refs/tags/v')" | |
run: | | |
docker export $(docker create shellhubio/agent:${{ env.RELEASE_VERSION }}-${{ matrix.dockerfile }}) | gzip > rootfs-${{ matrix.dockerfile }}.tar.gz | |
- name: upload rootfs artifact | |
if: "contains(github.ref, 'refs/tags/v')" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rootfs-${{ matrix.dockerfile }} | |
path: rootfs-${{ matrix.dockerfile }}.tar.gz | |
multiarch: | |
if: github.event_name != 'pull_request' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v4 | |
- name: Set github reference env | |
run: echo RELEASE_VERSION=${GITHUB_REF#refs/*/} >> $GITHUB_ENV | |
- name: login to docker hub | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: build multiarch image | |
if: "!contains(github.ref, 'refs/tags/v')" | |
env: | |
DOCKER_CLI_EXPERIMENTAL: enabled | |
run: | | |
echo "Creating the manifest" | |
docker manifest create -a shellhubio/agent:${{ github.sha }} shellhubio/agent:${{ github.sha }}-amd64 shellhubio/agent:${{ github.sha }}-arm32v6 shellhubio/agent:${{ github.sha }}-arm32v7 shellhubio/agent:${{ github.sha }}-arm64v8 | |
echo "Running amd64 manifest annotation" | |
docker manifest annotate shellhubio/agent:${{ github.sha }} shellhubio/agent:${{ github.sha }}-amd64 --os linux --arch amd64 | |
archname=(arm32v6 arm32v7 arm64v8) | |
arch=(arm arm arm64) | |
variant=(v6 v7 v8) | |
for ((i = 0; i < 3; i++)) ; do | |
echo "Running ${archname[i]} manifest annotation" | |
docker manifest annotate shellhubio/agent:${{ github.sha }} shellhubio/agent:${{ github.sha }}-${archname[i]} --os linux --arch ${arch[i]} --variant ${variant[i]} | |
done | |
echo "Pushing multiarch manifest" | |
docker manifest push shellhubio/agent:${{ github.sha }} | |
- name: build multiarch image from github tag | |
if: contains(github.ref, 'refs/tags/v') | |
env: | |
DOCKER_CLI_EXPERIMENTAL: enabled | |
run: | | |
echo "Creating the manifest" | |
docker manifest create -a shellhubio/agent:${{ env.RELEASE_VERSION }} shellhubio/agent:${{ env.RELEASE_VERSION }}-amd64 shellhubio/agent:${{ env.RELEASE_VERSION }}-arm32v6 shellhubio/agent:${{ env.RELEASE_VERSION }}-arm32v7 shellhubio/agent:${{ env.RELEASE_VERSION }}-arm64v8 | |
echo "Running amd64 manifest annotation" | |
docker manifest annotate shellhubio/agent:${{ env.RELEASE_VERSION }} shellhubio/agent:${{ env.RELEASE_VERSION }}-amd64 --os linux --arch amd64 | |
archname=(arm32v6 arm32v7 arm64v8) | |
arch=(arm arm arm64) | |
variant=(v6 v7 v8) | |
for ((i = 0; i < 3; i++)) ; do | |
echo "Running ${archname[i]} manifest annotation" | |
docker manifest annotate shellhubio/agent:${{ env.RELEASE_VERSION }} shellhubio/agent:${{ env.RELEASE_VERSION }}-${archname[i]} --os linux --arch ${arch[i]} --variant ${variant[i]} | |
done | |
echo "Pushing multiarch manifest" | |
docker manifest push shellhubio/agent:${{ env.RELEASE_VERSION }} | |
vendored-tarball: | |
if: "contains(github.ref, 'refs/tags/v')" | |
needs: build | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v4 | |
- name: export agent tarball | |
run: | | |
cd ./agent && go mod vendor && cd .. && tar czf shellhub-agent.tar.gz agent | |
- name: upload agent tarball artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: shellhub-agent | |
path: shellhub-agent.tar.gz | |
draft: | |
if: "contains(github.ref, 'refs/tags/v')" | |
needs: vendored-tarball | |
runs-on: ubuntu-latest | |
steps: | |
- name: download amd64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: rootfs-amd64 | |
- name: download arm32v6 | |
uses: actions/download-artifact@v4 | |
with: | |
name: rootfs-arm32v6 | |
- name: download arm32v7 | |
uses: actions/download-artifact@v4 | |
with: | |
name: rootfs-arm32v7 | |
- name: download arm64v8 | |
uses: actions/download-artifact@v4 | |
with: | |
name: rootfs-arm64v8 | |
- name: download i386 | |
uses: actions/download-artifact@v4 | |
with: | |
name: rootfs-i386 | |
- name: download vendored tarball | |
uses: actions/download-artifact@v4 | |
with: | |
name: shellhub-agent | |
- name: release draft | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
generate_release_notes: true | |
files: | | |
rootfs-*.tar.gz | |
shellhub-agent.tar.gz |