Publish workflows-worker #148
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: Publish workflows-worker | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: 'Worker package to update' | |
| required: true | |
| type: choice | |
| options: | |
| - datashare-asr-worker | |
| - datashare-extract-worker | |
| - datashare-python | |
| - datashare-passport-worker | |
| - datashare-translation-worker | |
| package_version: | |
| description: 'New version of the worker app' | |
| required: true | |
| type: string | |
| package_extras: | |
| description: 'Python package extras' | |
| required: false | |
| default: "" | |
| type: string | |
| env: | |
| PACKAGE: ${{ inputs.package }} | |
| PACKAGE_EXTRAS: ${{ inputs.package_extras }} | |
| PACKAGE_VERSION: ${{ inputs.package_version }} | |
| PYTHON_VERSION: 3.12 | |
| ASTRAL_VERSION: 0.11.6 | |
| jobs: | |
| bump-workflows-worker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| outputs: | |
| workflows_worker_tag: ${{ steps.tag.outputs.workflows_worker_tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| # We checkout main to avoid creating a tag from a detached head | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git pull | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: ${{ env.ASTRAL_VERSION }} | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| enable-cache: true | |
| working-directory: workers/workflows-worker | |
| - name: Bump workflows worker | |
| run: | | |
| cd workers/workflows-worker | |
| workflows_worker_version_bump_info=$(uv run --frozen main.py "$PACKAGE" "$PACKAGE_VERSION") | |
| echo workflows_worker_version_bump_info="$workflows_worker_version_bump_info" >> "$GITHUB_ENV" | |
| ./bump_workflow.sh "$PACKAGE$PACKAGE_EXTRAS" "$PACKAGE_VERSION" | |
| - name: Create a new workflows worker tags | |
| id: tag | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| raw_version=$(echo $workflows_worker_version_bump_info | jq -r .next) | |
| workflows_worker_version="workflows-worker-$raw_version" | |
| bump_type="$(echo $workflows_worker_version_bump_info | jq -r .bump_type)" | |
| cd workers/workflows-worker | |
| uv version --frozen --bump $bump_type | |
| cd ../.. | |
| make lock-dist project=workflows-worker | |
| cd workers/workflows-worker/ | |
| uv sync --frozen | |
| uv pip list | |
| git add uv.lock uv.dist.lock pyproject.toml | |
| git status | |
| echo "workflows_worker_tag=$raw_version" >> "$GITHUB_OUTPUT" | |
| git commit -m "release(workflows-worker): bump version to $workflows_worker_version" | |
| git pull --rebase | |
| git tag "$workflows_worker_version" | |
| git push && git push --tags | |
| gh release create "$workflows_worker_version" --generate-notes | |
| publish-workflows-worker: | |
| runs-on: ubuntu-latest | |
| needs: bump-workflows-worker | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| # We checkout main to avoid creating a tag from a detached head | |
| ref: workflows-worker-${{ needs.bump-workflows-worker.outputs.workflows_worker_tag }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: icij/datashare-workflows-worker | |
| tags: | | |
| type=raw,value=${{ needs.bump-workflows-worker.outputs.workflows_worker_tag }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| # You'll need to set these secrets | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| target: datashare-workflows-worker | |
| context: ./workers/workflows-worker | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false |