Skip to content

Bump version to 2.10.1 #138

Bump version to 2.10.1

Bump version to 2.10.1 #138

Workflow file for this run

name: Run CI/CD
on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
inputs:
stage:
description: Stage
type: choice
required: true
options:
- beta
- prod
hexdoc-release:
description: Force a web book release
type: boolean
env:
REGISTRY: ghcr.io
IMAGE_NAME: object-object/hexbug
VERSION_REGEX: 'v[0-9]+(\.[0-9]+)+'
jobs:
setup:
runs-on: ubuntu-latest
outputs:
stage: ${{ steps.get-stage.outputs.stage }}
hexdoc-release: ${{ steps.get-stage.outputs.stage == 'prod' || inputs.hexdoc-release }}
steps:
- name: Get deployment stage
id: get-stage
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
STAGE="${{ inputs.stage }}"
elif [[ "${{ github.ref }}" =~ ^refs/tags/${{ env.VERSION_REGEX }}$ ]]; then
STAGE="prod"
else
STAGE="beta"
fi
echo "Deployment stage: \`$STAGE\`" | tee >> $GITHUB_STEP_SUMMARY
echo "stage=$STAGE" >> "$GITHUB_OUTPUT"
build:
needs:
- setup
uses: ./.github/workflows/build.yml
secrets: inherit
with:
stage: ${{ needs.setup.outputs.stage }}
hexdoc-release: ${{ needs.setup.outputs.hexdoc-release == 'true' }}
check:
needs:
- setup
- build
runs-on: ubuntu-latest
outputs:
deploy-bot: ${{ steps.check-workflows.outputs.result == 'ok' }}
steps:
- name: Check for active prod deployments triggered by tag push
id: check-workflows
uses: actions/github-script@v8
env:
STAGE: ${{ needs.setup.outputs.stage }}
with:
result-encoding: string
script: |
if (process.env.STAGE === "prod") {
return "ok";
}
const response = await github.rest.actions.listWorkflowRuns({
...context.repo,
workflow_id: process.env.GITHUB_WORKFLOW_REF.match(/\/([^/]+\.ya?ml)@/)[1],
event: "push",
status: "in_progress",
exclude_pull_requests: true,
});
console.dir(response, { depth: null })
for (const run of response.data.workflow_runs) {
if (
run.head_branch?.match(/^${{ env.VERSION_REGEX }}$/) != null
&& run.id !== context.runId
) {
console.log("Found active deployment:", run.html_url);
return "not_ok";
}
}
return "ok";
push-image:
needs:
- setup
- build
- check
if: needs.check.outputs.deploy-bot == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
environment:
name: docker
url: https://${{ needs.build.outputs.image-tag }}
outputs:
digest: ${{ steps.digest.outputs.value }}
steps:
- uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: docker-image
path: ${{ runner.temp }}
- name: Load image
run: docker load --input ${{ runner.temp }}/image.tar
- name: Push image
run: docker image push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Get image digest
id: digest
run: echo "value=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ needs.build.outputs.image-tag }})" >> "$GITHUB_OUTPUT"
deploy-beta:
needs:
- setup
- build
- push-image
uses: ./.github/workflows/deploy-bot.yml
permissions:
contents: read
id-token: write
secrets: inherit
with:
stage: beta
image-digest: ${{ needs.push-image.outputs.digest }}
deploy-prod:
needs:
- setup
- build
- push-image
- deploy-beta
if: needs.setup.outputs.stage == 'prod'
uses: ./.github/workflows/deploy-bot.yml
permissions:
contents: read
id-token: write
secrets: inherit
with:
stage: prod
image-digest: ${{ needs.push-image.outputs.digest }}
deploy-pages:
needs:
- setup
- build
runs-on: ubuntu-latest
concurrency:
group: hexdoc-deploy-pages
cancel-in-progress: false
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: object-Object/ci/setup@v0
with:
python-version-file: .python-version
- name: Sync dependencies
run: |
export UV_PROJECT_ENVIRONMENT="${pythonLocation}"
uv sync --locked --no-dev --package HexBug-web
- name: Download hexdoc.toml artifact
uses: actions/download-artifact@v4
with:
name: hexdoc-toml
- name: Merge hexdoc
uses: hexdoc-dev/actions/merge@v1
with:
release: ${{ needs.setup.outputs.hexdoc-release == 'true' }}
site-url: ${{ needs.build.outputs.pages-url }}
- name: Download activity artifact
uses: actions/download-artifact@v4
with:
name: activity
path: _site/dst/docs/hexbug-${{ needs.setup.outputs.stage }}-activity
- name: Deploy to Pages
uses: hexdoc-dev/actions/deploy-pages@v1
with:
merge: false
release: ${{ needs.setup.outputs.hexdoc-release == 'true' }}
publish-pypi:
needs:
- setup
- build
- deploy-pages
if: needs.setup.outputs.stage == 'prod'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/HexBug-data
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: hexdoc-build
path: dist
- name: Remove extraneous files
run: rm dist/*.txt dist/*.toml
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1