|
| 1 | +# Action to publish development Docker images |
| 2 | +# Images are versioned as `0.0.0-{tag}-DATETIMESTAMP` |
| 3 | +name: Development Image Release |
| 4 | + |
| 5 | +on: workflow_dispatch |
| 6 | + |
| 7 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 8 | + |
| 9 | +jobs: |
| 10 | + release-docker-image: |
| 11 | + name: Build and Release powersync-service Docker Image |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + # check out full history |
| 18 | + # Temporarily needed for changesets |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Set up QEMU |
| 22 | + uses: docker/setup-qemu-action@v3 |
| 23 | + |
| 24 | + - name: Set up Docker Buildx |
| 25 | + uses: docker/setup-buildx-action@v3 |
| 26 | + |
| 27 | + - name: Login to Docker Hub |
| 28 | + uses: docker/login-action@v3 |
| 29 | + with: |
| 30 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 31 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Setup NodeJS |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version-file: '.nvmrc' |
| 37 | + |
| 38 | + - uses: pnpm/action-setup@v2 |
| 39 | + name: Install pnpm |
| 40 | + with: |
| 41 | + version: 9 |
| 42 | + run_install: false |
| 43 | + |
| 44 | + - name: Add NPM auth |
| 45 | + run: | |
| 46 | + echo //npm.pkg.github.com/:_authToken=\${{secrets.RESTRICTED_PACKAGES_TOKEN}} >> ~/.npmrc |
| 47 | + echo "//npm.pkg.github.com/journeyapps-platform/:_authToken=${{secrets.RESTRICTED_PACKAGES_TOKEN}}" >> ~/.npmrc |
| 48 | + echo "@journeyapps-platform:registry=https://npm.pkg.github.com/journeyapps-platform/" >> ~/.npmrc |
| 49 | +
|
| 50 | + - name: Get pnpm store directory |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 54 | +
|
| 55 | + - uses: actions/cache@v3 |
| 56 | + name: Setup pnpm cache |
| 57 | + with: |
| 58 | + path: ${{ env.STORE_PATH }} |
| 59 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-pnpm-store- |
| 62 | +
|
| 63 | + - name: Install dependencies |
| 64 | + run: pnpm install |
| 65 | + |
| 66 | + - name: Ensure Changesets |
| 67 | + run: | |
| 68 | + # If no changesets are available the status check will fail |
| 69 | + # We should not continue if there are no changesets |
| 70 | + pnpm changeset status |
| 71 | + pnpm changeset version --no-git-tag --snapshot dev |
| 72 | +
|
| 73 | + # This uses the service's package.json version for the Docker Image tag |
| 74 | + # The changeset command above should change this to a dev package |
| 75 | + - name: Get Service Version from package.json |
| 76 | + id: get_version |
| 77 | + run: echo "SERVICE_VERSION=$(node -p "require('./service/package.json').version")" >> $GITHUB_OUTPUT |
| 78 | + |
| 79 | + - name: Build Image and Push |
| 80 | + uses: docker/build-push-action@v5 |
| 81 | + with: |
| 82 | + platforms: linux/arm64,linux/amd64 |
| 83 | + cache-from: type=registry,ref=${{vars.DOCKER_REGISTRY}}:latest |
| 84 | + context: . |
| 85 | + # This should not be taged as latest |
| 86 | + tags: ${{vars.DOCKER_REGISTRY}}:${{steps.get_version.outputs.SERVICE_VERSION}} |
| 87 | + push: true |
| 88 | + file: ./service/Dockerfile |
| 89 | + # TODO remove this when removing Journey Micro |
| 90 | + build-args: | |
| 91 | + GITHUB_TOKEN=${{secrets.RESTRICTED_PACKAGES_TOKEN}} |
0 commit comments