diff --git a/.github/workflows/build-deploy-release-multi.yaml b/.github/workflows/build-deploy-release-multi.yaml new file mode 100644 index 0000000..6407b1d --- /dev/null +++ b/.github/workflows/build-deploy-release-multi.yaml @@ -0,0 +1,92 @@ +# +# Builds tests amd64 and arm64 images (separately, to reduce image size) +# +name: build-deploy-release-multi +on: + push: + release: + types: [published] + +jobs: + build: + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - ubuntu-22-arm64-4-16 + include: + - os: ubuntu-latest + arch: amd64 + - os: ubuntu-22-arm64-4-16 + arch: arm64 + + runs-on: ${{ matrix.os }} + + env: + registry: us-west1-docker.pkg.dev + image: geocoder-${{ matrix.arch }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: create latest tag variable + run: | + container="${{ env.registry }}/${{ secrets.PROJECT_ID }}/${{ secrets.REPOSITORY }}/${{ env.image }}:latest" + echo "container=${container}" >> $GITHUB_ENV + + - name: create release tag variable + if: github.event_name == 'release' + run: | + versioned="${{ env.registry }}/${{ secrets.PROJECT_ID }}/${{ secrets.REPOSITORY }}/${{ env.image }}:${GITHUB_REF##*/}" + echo "versioned=${versioned}" >> $GITHUB_ENV + + - name: Authenticate with Google Cloud + uses: google-github-actions/auth@v2 + with: + project_id: ${{ secrets.PROJECT_ID }} + workload_identity_provider: ${{ secrets.IDENTITY_PROVIDER }} + + - name: Set up Cloud SDK + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' + + - name: Configure docker for Google artifact registry + id: docker + run: gcloud auth configure-docker ${{ env.registry }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + id: build + uses: docker/build-push-action@v6 + with: + context: . + cache-from: type=gha + cache-to: type=gha,mode=max + load: true + tags: ${{ env.container }} + + - name: Test image + id: test + run: | + docker run --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv + docker run --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv 0.6 + docker run --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv all + + - name: Push image + id: push + uses: docker/build-push-action@v6 + with: + context: . + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + tags: | + ${{ env.container }} + ${{ env.versioned }} + diff --git a/.github/workflows/build-stanford.yaml b/.github/workflows/build-stanford.yaml deleted file mode 100644 index bf040e3..0000000 --- a/.github/workflows/build-stanford.yaml +++ /dev/null @@ -1,108 +0,0 @@ -# -# Builds and tests a multi-arch (amd64/arm64) image -# -name: build-stanford -on: - release: - types: [published] - -jobs: - deploy-images: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - - env: - registry: ghcr.io - username: susom - repository: geocoder - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: create latest tag variable - run: | - container="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:latest" - echo "container=${container}" >> $GITHUB_ENV - - - name: create release tag variable - if: github.event_name == 'release' - run: | - versioned="${{ env.registry }}/${{ env.username}}/${{ env.repository }}:${GITHUB_REF##*/}" - echo "versioned=${versioned}" >> $GITHUB_ENV - - - name: Free disk space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - android: true - dotnet: true - haskell: true - large-packages: true - docker-images: true - swap-storage: true - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build AMD64 image - id: build-amd64 - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max - load: true - tags: ${{ env.container }} - - - name: Test AMD64 image - id: test-amd64 - run: | - docker run --platform linux/amd64 --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv - docker run --platform linux/amd64 --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv 0.6 - docker run --platform linux/amd64 --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv all - - - name: Build ARM64 image - id: build-arm64 - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - load: true - tags: ${{ env.container }} - - - name: Test ARM64 image - id: test-arm64 - run: | - docker run --platform linux/arm64 --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv - docker run --platform linux/arm64 --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv 0.6 - docker run --platform linux/arm64 --rm -v "${PWD}/test":/tmp ${{ env.container }} my_address_file.csv all - - - name: Login to ghcr - uses: docker/login-action@v1 - with: - registry: ${{ env.registry }} - username: ${{ env.username }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Push multi-arch image - id: push - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - push: true - tags: | - ${{ env.container }} - ${{ env.versioned }} -