Docker Stable Release #1
Workflow file for this run
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: Docker Stable Release | |
| on: workflow_dispatch | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| release-docker-image: | |
| name: Promote powersync-service Docker image to stable | |
| runs-on: ubuntu-latest | |
| environment: dockerhub | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| # check out full history | |
| # Temporarily needed for changesets | |
| fetch-depth: 0 | |
| # This uses the service's package.json version for the Docker Image tag | |
| - name: Validate release tag | |
| id: version | |
| run: | | |
| if [ "$GITHUB_REF_TYPE" != "tag" ]; then | |
| echo "This workflow must be run against a git tag, e.g. gh workflow run docker-stable --ref v1.21.0" >&2 | |
| exit 1 | |
| fi | |
| version="$(node -p "require('./service/package.json').version")" | |
| tag="$GITHUB_REF_NAME" | |
| if [ "$tag" != "v$version" ]; then | |
| echo "Git tag $tag does not match service package version $version" >&2 | |
| exit 1 | |
| fi | |
| node -e "const parts = process.argv[1].split('.'); if (parts.length !== 3 || parts.some((part) => !/^\\d+$/.test(part))) process.exit(1)" "$version" | |
| major="${version%%.*}" | |
| minor_patch="${version#*.}" | |
| minor="${minor_patch%%.*}" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "major=$major" >> "$GITHUB_OUTPUT" | |
| echo "minor=$minor" >> "$GITHUB_OUTPUT" | |
| - 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: Promote next image tags to stable | |
| run: | | |
| docker buildx imagetools inspect "${{ vars.DOCKER_REGISTRY }}:${{ steps.version.outputs.version }}-next" > /dev/null | |
| docker buildx imagetools create \ | |
| --tag "${{ vars.DOCKER_REGISTRY }}:${{ steps.version.outputs.version }}" \ | |
| --tag "${{ vars.DOCKER_REGISTRY }}:${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" \ | |
| --tag "${{ vars.DOCKER_REGISTRY }}:${{ steps.version.outputs.major }}" \ | |
| --tag "${{ vars.DOCKER_REGISTRY }}:latest" \ | |
| "${{ vars.DOCKER_REGISTRY }}:${{ steps.version.outputs.version }}-next" | |
| # Updates the README section on the DockerHub page | |
| - name: Update repo description | |
| # Note that this 3rd party extention is recommended in the DockerHub docs: | |
| # https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/ | |
| uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: ${{ vars.DOCKER_REGISTRY }} | |
| # This is the contents of what will be shown on DockerHub | |
| readme-filepath: ./service/README.md |