2. Build and Publish #7
This file contains hidden or 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: 2. Build and Publish | |
| on: | |
| workflow_run: | |
| workflows: ["1. Bump Version"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| push: | |
| tags: | |
| - "v*.*.*-*" | |
| env: | |
| _VERSION: 0.0.0-250101 | |
| jobs: | |
| build_publish: | |
| name: Build and Publish | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| actions: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Get latest version | |
| run: | | |
| git pull origin main | |
| echo "Current version: v$(./scripts/get-version.sh)" | |
| # - name: Free disk space | |
| # run: | | |
| # sudo swapoff -a | |
| # sudo rm -f /swapfile | |
| # sudo apt clean | |
| # docker system prune -af | |
| # df -h | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| ## Latest version causes segfault: | |
| ## https://github.com/docker/setup-qemu-action/issues/198 | |
| image: tonistiigi/binfmt:qemu-v7.0.0-28 | |
| - name: Set up docker buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to docker hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Get version | |
| run: echo "_VERSION=$(./scripts/get-version.sh)" >> ${GITHUB_ENV} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| # platforms: linux/amd64,linux/arm64 | |
| secrets: | | |
| "HASH_PASSWORD=${{ secrets.DOCKER_UID_HASH_PASSWORD }}" | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/agent-validator:cache-latest | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/agent-validator:cache-latest,mode=max | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/agent-validator:${{ env._VERSION }} | |
| push: true | |
| - name: Trigger release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh workflow run 3.create-release.yml |