name: Reusable build workflow on: workflow_call: inputs: ref: description: 'The branch, tag or SHA to build' required: true type: string release: description: 'Release version tag for this build' default: '' required: false type: string docker: description: 'Build docker images' default: false required: true type: boolean docker_repository: description: 'Docker Hub Repository' default: '' required: false type: string docker_tag_prefix: description: 'Docker Image Tag Prefix' default: '' required: false type: string additional_tags: description: 'Additional Docker Image Tags (JSON)' default: '' required: false type: string secrets: DOCKERHUB_USERNAME: description: 'Docker Hub Username' required: false DOCKERHUB_TOKEN: description: 'Docker Hub Token' required: false # shared build jobs jobs: build_frontend: name: Build frontend runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} - name: Set up Node.js uses: actions/setup-node@v6 with: node-version: '20' - name: Build frontend run: make ui # upload artifacts - name: "Upload artifact: frontend" uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: path: ./pkg/web/static/ name: frontend build_linux_amd64_binary: name: Build linux/amd64 binary needs: [build_frontend] runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} # setup global dependencies - name: Set up go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version: 1.25.x # download frontend artifacts - name: Download frontend artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: frontend path: ./pkg/web/static # setup project dependencies - name: Get dependencies run: | go get -v -t -d ./... # build binaries - name: Build linux amd64 binary run: | make docs make build env: RELEASE: ${{ inputs.release }} # upload artifacts - name: "Upload artifact: assertoor_linux_amd64" uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: path: ./bin/* name: assertoor_linux_amd64 build_linux_arm64_binary: name: Build linux/arm64 binary needs: [build_frontend] runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} # setup global dependencies - name: Set up go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version: 1.25.x # download frontend artifacts - name: Download frontend artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: frontend path: ./pkg/web/static # setup project dependencies - name: Get dependencies run: | go get -v -t -d ./... # build binaries - name: Build linux arm64 binary run: | make docs make build env: RELEASE: ${{ inputs.release }} # upload artifacts - name: "Upload artifact: assertoor_linux_arm64" uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: path: ./bin/* name: assertoor_linux_arm64 build_windows_binary: name: Build windows/amd64 binary needs: [build_frontend] runs-on: windows-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} # setup global dependencies - name: Set up go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version: 1.25.x # download frontend artifacts - name: Download frontend artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: frontend path: ./pkg/web/static # setup project dependencies - name: Get dependencies run: | go get -v -t -d ./... # build binaries - name: Build windows binary run: | make docs make build env: RELEASE: ${{ inputs.release }} # upload artifacts - name: "Upload artifact: assertoor_windows_amd64" uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: path: ./bin/* name: assertoor_windows_amd64 build_darwin_amd64_binary: name: Build macos/amd64 binary needs: [build_frontend] runs-on: macos-15-intel steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} # setup global dependencies - name: Set up go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version: 1.25.x # download frontend artifacts - name: Download frontend artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: frontend path: ./pkg/web/static # setup project dependencies - name: Get dependencies run: | go get -v -t -d ./... # build binaries - name: Build macos amd64 binary run: | make docs make build env: RELEASE: ${{ inputs.release }} # upload artifacts - name: "Upload artifact: assertoor_darwin_amd64" uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: path: ./bin/* name: assertoor_darwin_amd64 build_darwin_arm64_binary: name: Build macos/arm64 binary needs: [build_frontend] runs-on: macos-26 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} # setup global dependencies - name: Set up go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version: 1.25.x # download frontend artifacts - name: Download frontend artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: frontend path: ./pkg/web/static # setup project dependencies - name: Get dependencies run: | go get -v -t -d ./... # build binaries - name: Build macos arm64 binary run: | make docs make build env: RELEASE: ${{ inputs.release }} # upload artifacts - name: "Upload artifact: assertoor_darwin_arm64" uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: path: ./bin/* name: assertoor_darwin_arm64 build_amd64_docker_image: name: Build amd64 docker image needs: [build_linux_amd64_binary] if: ${{ inputs.docker }} runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} - name: Get build version id: vars run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT # prepare docker - name: Set up Docker Buildx uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - name: Login to Docker Hub uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} # download build artifacts - name: Download build artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: assertoor_linux_amd64 path: ./bin # prepare environment - name: Prepare build environment run: | chmod +x ./bin/* ls -lach ./bin # build amd64 image - name: Build amd64 docker image run: | docker build . --file Dockerfile-stub \ --tag ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-amd64 \ --tag ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 \ --platform=linux/amd64 - name: Push amd64 docker images run: | docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-amd64 docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 build_arm64_docker_image: name: Build arm64 docker image needs: [build_linux_arm64_binary] if: ${{ inputs.docker }} runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} - name: Get build version id: vars run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT # prepare docker - name: Set up Docker Buildx uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - name: Login to Docker Hub uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} # download build artifacts - name: Download build artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: assertoor_linux_arm64 path: ./bin # prepare environment - name: Prepare build environment run: | chmod +x ./bin/* ls -lach ./bin # build arm64 image - name: Build arm64 docker image run: | docker build . --file Dockerfile-stub \ --tag ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-arm64 \ --tag ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64 \ --platform=linux/arm64 - name: Push arm64 docker image run: | docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-arm64 docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64 build_multiarch_image: name: Build multiarch docker image needs: [build_amd64_docker_image, build_arm64_docker_image] if: ${{ inputs.docker }} runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} - name: Get build version id: vars run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT # prepare docker - name: Set up Docker Buildx uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - name: Login to Docker Hub uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} # build multiarch image - name: Build multiarch docker manifest run: | docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }} \ ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 \ ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64 build_extra_image: name: Build additional docker manifests needs: [build_multiarch_image] if: ${{ inputs.additional_tags }} runs-on: ubuntu-latest strategy: matrix: tag: ${{ fromJSON(inputs.additional_tags) }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ inputs.ref }} - name: Get build version id: vars run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT # prepare docker - name: Set up Docker Buildx uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - name: Login to Docker Hub uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} # build multiarch image - name: "Build additional docker manifest: ${{ matrix.tag }}" run: | docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ matrix.tag }}-amd64 \ ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ matrix.tag }}-arm64 \ ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64 docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ matrix.tag }} \ ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 \ ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64