Release Candidate v4.14.20 #189
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: Build Beta | |
| on: | |
| pull_request: | |
| branches: | |
| - release | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.user.login != 'dependabot[bot]' | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 100 | |
| - name: Print build name | |
| run: echo "$GITHUB_ACTOR is building '$GITHUB_REPOSITORY' (commit $GITHUB_SHA)" | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/pip | |
| ~/.local/share/virtualenvs | |
| key: ${{ runner.os }}-dependency-cache | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12.6" | |
| - name: Install dependencies | |
| run: | | |
| pip install --no-cache-dir pipenv | |
| pipenv install --dev | |
| - name: Lint checks | |
| run: ./tools/run_lint.sh | |
| - name: Test the service | |
| env: | |
| BUILD_QUALITY: "BETA" | |
| LOG_LEVEL: "trace" | |
| run: pipenv run pytest -v | |
| - name: Build Docker image | |
| run: docker build . --file Dockerfile --tag the-agent | |
| - name: Auth for GitHub's Docker repository | |
| env: | |
| USER: ${{ secrets.PACKAGES_USER }} | |
| TOKEN: ${{ secrets.PACKAGES_TOKEN }} | |
| run: echo $TOKEN | docker login docker.pkg.github.com --username $USER --password-stdin | |
| - name: Tag Docker image | |
| run: | | |
| VERSION=$(cat .version | tr -d '[:space:]') | |
| echo "Tagging images with version '$VERSION'..." | |
| docker tag the-agent docker.pkg.github.com/$GITHUB_REPOSITORY/the-agent:"$VERSION".beta | |
| docker tag the-agent docker.pkg.github.com/$GITHUB_REPOSITORY/the-agent:latest_beta | |
| docker tag the-agent appifyhub/the-agent:"$VERSION".beta | |
| docker tag the-agent appifyhub/the-agent:latest_beta | |
| - name: Publish Docker images to GitHub | |
| run: | | |
| VERSION=$(cat .version | tr -d '[:space:]') | |
| echo "Publishing images with version '$VERSION'..." | |
| docker push docker.pkg.github.com/$GITHUB_REPOSITORY/the-agent:"$VERSION".beta | |
| docker push docker.pkg.github.com/$GITHUB_REPOSITORY/the-agent:latest_beta | |
| - name: Publish Docker images to DockerHub | |
| id: docker_publish | |
| env: | |
| USER: ${{ secrets.DOCKER_HUB_USER }} | |
| TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
| run: | | |
| VERSION=$(cat .version | tr -d '[:space:]') | |
| docker login docker.io -u $USER -p $TOKEN | |
| echo "Publishing images with version '$VERSION'..." | |
| docker push appifyhub/the-agent:"$VERSION".beta | |
| docker push appifyhub/the-agent:latest_beta | |
| echo ::set-output name=the_agent_version::"$VERSION" | |
| - name: Comment build information | |
| env: | |
| GITHUB_SHA: ${{ env.GITHUB_SHA }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_RUN_ID: ${{ env.GITHUB_RUN_ID }} | |
| GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY }} | |
| GITHUB_SERVER_URL: ${{ env.GITHUB_SERVER_URL }} | |
| PR_NUMBER: ${{ github.event.number }} | |
| VERSION: ${{ steps.docker_publish.outputs.the_agent_version }} | |
| DOCKER_IMG: "docker pull appifyhub/the-agent" | |
| run: | | |
| NL=$'\n' | |
| CODE='```' | |
| DOCKER_VERSIONED="$DOCKER_IMG:$VERSION.beta" | |
| DOCKER_LATEST="# Valid until a new build${NL}${DOCKER_IMG}:latest_beta" | |
| CODE_BLOCK="${CODE}shell${NL}${DOCKER_LATEST}${NL}${DOCKER_VERSIONED}${NL}${CODE}" | |
| JOB="[${GITHUB_RUN_ID}](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})" | |
| NOTIFICATION="Build ${JOB} complete for ${GITHUB_SHA}.${NL}${NL}${CODE_BLOCK}${NL}" | |
| gh pr comment "$PR_NUMBER" -b "$NOTIFICATION" | |
| - name: Publish to GitHub Releases | |
| id: publish_github_release | |
| env: | |
| ARTIFACT: "the-agent" | |
| BUILD_QUALITY: "BETA" | |
| VERSION: ${{ steps.docker_publish.outputs.the_agent_version }} | |
| GITHUB_SHA: ${{ env.GITHUB_SHA }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY }} | |
| run: pipenv run python tools/publish_github_release.py | |
| - name: Wait for the service to go live | |
| env: | |
| HEALTH_ENDPOINT: ${{ secrets.HEALTH_ENDPOINT_STAGING }} | |
| EXPECTED_VERSION: ${{ steps.publish_github_release.outputs.release_version }} # stored in Python | |
| run: | | |
| INTERVAL=15 | |
| DURATION_MINUTES=12 | |
| ATTEMPTS=$(( (DURATION_MINUTES * 60) / INTERVAL )) | |
| echo "Waiting for health endpoint to report version: $EXPECTED_VERSION" | |
| echo "Polling every $INTERVAL seconds for $DURATION_MINUTES minutes ($ATTEMPTS attempts)" | |
| for ((i=1;i<=ATTEMPTS;i++)); do | |
| RESPONSE=$(curl -s "$HEALTH_ENDPOINT" || true) | |
| VERSION=$(echo "$RESPONSE" | grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' | head -n1 | sed 's/.*: *"\([^"]*\)".*/\1/') | |
| if [[ "$VERSION" == "$EXPECTED_VERSION" ]]; then | |
| echo "Health endpoint version matches: $VERSION" | |
| exit 0 | |
| fi | |
| echo "Attempt $i/$ATTEMPTS: version is '$VERSION', waiting..." | |
| sleep $INTERVAL | |
| done | |
| echo "Waited full $DURATION_MINUTES minutes. Version did not match. Continuing." | |
| exit 0 | |
| - name: Notify of release | |
| id: notify_release | |
| env: | |
| NOTIFICATION_AUTH_KEY: ${{ secrets.NOTIFICATION_AUTH_KEY_STAGING }} | |
| NOTIFICATION_ENDPOINT: ${{ secrets.NOTIFICATION_URL_STAGING }} | |
| RELEASE_OUTPUT_B64: ${{ steps.publish_github_release.outputs.release_output_b64 }} # stored in Python | |
| run: | | |
| SUMMARY_RESPONSE=$(curl -X POST \ | |
| -L "$NOTIFICATION_ENDPOINT" \ | |
| -H "X-API-Key: $NOTIFICATION_AUTH_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"release_output_b64\": \"$RELEASE_OUTPUT_B64\"}" \ | |
| --silent --show-error) | |
| SUMMARY=$(echo "$SUMMARY_RESPONSE" | jq -r '.summary // empty') | |
| SUMMARY_B64=$(printf "%s" "$SUMMARY" | base64 -w 0) | |
| echo "summary_b64=$SUMMARY_B64" >> $GITHUB_OUTPUT | |
| - name: Update GitHub Release with summary | |
| if: steps.notify_release.outputs.summary_b64 != '' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY }} | |
| RELEASE_TAG: ${{ steps.publish_github_release.outputs.release_tag }} # stored in Python | |
| SUMMARY_B64: ${{ steps.notify_release.outputs.summary_b64 }} # stored in the task above | |
| run: | | |
| SUMMARY=$(echo "$SUMMARY_B64" | base64 --decode) | |
| echo "$SUMMARY" > summary.txt | |
| gh release edit "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --notes-file summary.txt | |
| - name: Update PR with summary | |
| if: steps.notify_release.outputs.summary_b64 != '' && github.event.number | |
| env: | |
| PR_NUMBER: ${{ github.event.number }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SUMMARY_B64: ${{ steps.notify_release.outputs.summary_b64 }} # stored in the task above | |
| run: | | |
| SUMMARY=$(echo "$SUMMARY_B64" | base64 --decode) | |
| echo "$SUMMARY" > summary.txt | |
| gh pr edit "$PR_NUMBER" --body-file summary.txt |