Prep for Release 0.9.2 #72
This file contains 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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
REGISTRY: ghcr.io | |
REGISTRYPATH: ghcr.io/stac-utils | |
DOCKER_BUILDKIT: 1 | |
jobs: | |
check-pgstac-base: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
pgstac-image-exists: ${{ steps.pgstac_image_check.outputs.pgstac-image-exists }} | |
pgstac-image-hash: ${{ steps.pgstac_image_check.outputs.pgstac-image-hash }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check if pgstac-base docker image needs to be updated | |
id: pgstac_image_check | |
run: | | |
set -e | |
IMAGE=stac-utils/pgstac-base | |
HASH=$(git log -1 --pretty="format:%h" -- docker/pgstac) | |
TAG="\"$HASH\"" | |
TOKEN=$(curl -s https://ghcr.io/token\?scope\="repository:$IMAGE:pull" | jq -r .token) | |
EXISTS=$(curl -s -H "Authorization: Bearer $TOKEN" https://ghcr.io/v2/$IMAGE/tags/list | jq "try(any(.tags[]; . == $TAG))") | |
echo "pgstac-image-exists=$EXISTS" >>$GITHUB_OUTPUT | |
echo "pgstac-image-hash=$HASH" >>$GITHUB_OUTPUT | |
echo "pgstac-image-exists: $EXISTS" | |
echo "pgstac-image-hash: $HASH" | |
buildpg: | |
name: Build and push base postgres image | |
needs: [check-pgstac-base] | |
if: ${{ needs.check-pgstac-base.outputs.pgstac-image-exists != 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Display inputs | |
run: | | |
echo "Inputs:" | |
echo ${{ needs.check-pgstac-base.outputs.pgstac-image-exists }} | |
echo ${{ needs.check-pgstac-base.outputs.pgstac-image-hash }} | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Base Postgres | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64 | |
context: . | |
target: pgstacbase | |
file: docker/pgstac/Dockerfile | |
tags: ${{ env.REGISTRYPATH }}/pgstac-base:${{ needs.check-pgstac-base.outputs.pgstac-image-hash }} | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha, mode=max | |
check-pypgstac-base: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
pypgstac-image-exists: ${{ steps.pypgstac_image_check.outputs.pypgstac-image-exists }} | |
pypgstac-image-hash: ${{ steps.pypgstac_image_check.outputs.pypgstac-image-hash }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check if pypgstac-base docker image needs to be updated | |
id: pypgstac_image_check | |
run: | | |
set -e | |
IMAGE=stac-utils/pypgstac-base | |
HASH=$(git log -1 --pretty="format:%h" -- docker/pypgstac) | |
TAG="\"$HASH\"" | |
TOKEN=$(curl -s https://ghcr.io/token\?scope\="repository:$IMAGE:pull" | jq -r .token) | |
EXISTS=$(curl -s -H "Authorization: Bearer $TOKEN" https://ghcr.io/v2/$IMAGE/tags/list | jq "try(any(.tags[]; . == $TAG))") | |
echo "pypgstac-image-exists=$EXISTS" >>$GITHUB_OUTPUT | |
echo "pypgstac-image-hash=$HASH" >>$GITHUB_OUTPUT | |
echo "pypgstac-image-exists: $EXISTS" | |
echo "pypgstac-image-hash: $HASH" | |
buildpypgstacbase: | |
name: Build and push base pypgstac image | |
needs: [check-pypgstac-base] | |
if: ${{ needs.check-pypgstac-base.outputs.pypgstac-image-exists != 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Display inputs | |
run: | | |
echo "Inputs:" | |
echo ${{ needs.check-pypgstac-base.outputs.pypgstac-image-exists }} | |
echo ${{ needs.check-pypgstac-base.outputs.pypgstac-image-hash }} | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Base Postgres | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64 | |
context: . | |
target: pypgstac-base | |
file: docker/pypgstac/Dockerfile | |
tags: ${{ env.REGISTRYPATH }}/pypgstac-base:${{ needs.check-pypgstac-base.outputs.pypgstac-image-hash }} | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha, mode=max | |
wheels: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
working-directory: src/pypgstac | |
target: x86_64 | |
args: --release --out /home/runner/work/pgstac/pgstac/dist | |
sccache: 'true' | |
manylinux: auto | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels | |
path: /home/runner/work/pgstac/pgstac/dist/* | |
if-no-files-found: error | |
test: | |
needs: [check-pgstac-base, check-pypgstac-base, buildpg, buildpypgstacbase, wheels] | |
if: ${{ always() && !failure() && !cancelled() }} | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/stac-utils/pypgstac-base:${{ needs.check-pypgstac-base.outputs.pypgstac-image-hash }} | |
env: | |
PGHOST: localhost | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
PGDATABASE: postgres | |
volumes: | |
- ${{ github.workspace }}:/opt/src/ | |
services: | |
pg: | |
image: ghcr.io/stac-utils/pgstac-base:${{ needs.check-pgstac-base.outputs.pgstac-image-hash }} | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_DATABASE: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Wheel | |
uses: actions/download-artifact@v4 | |
with: | |
name: wheels | |
path: /tmp/wheels | |
- name: Install pypgstac | |
run: | | |
cd /opt/src/pypgstac | |
pwd | |
ls | |
source /venv/bin/activate | |
uv pip install --offline --find-links /tmp/wheels pypgstac | |
- name: Run tests | |
run: | | |
source /venv/bin/activate | |
/scripts/test | |
# linux_x86_64: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Build wheels | |
# uses: PyO3/maturin-action@v1 | |
# with: | |
# working-directory: src/pypgstac | |
# target: x86_64 | |
# args: --release --out ${{ env.GITHUB_WORKSPACE }}/dist | |
# sccache: 'true' | |
# manylinux: auto | |
# - name: Upload wheels | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: wheels-x86_64 | |
# path: ${{ env.GITHUB_WORKSPACE }}/dist/* | |
# if-no-files-found: error | |
# linux: | |
# if: false | |
# runs-on: ubuntu-latest | |
# strategy: | |
# matrix: | |
# target: [x86, aarch64, armv7, s390x, ppc64le] | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Build wheels | |
# uses: PyO3/maturin-action@v1 | |
# with: | |
# working-directory: src/pypgstac | |
# target: ${{ matrix.target }} | |
# args: --release --out ${{ env.GITHUB_WORKSPACE }}/dist | |
# sccache: 'true' | |
# manylinux: auto | |
# - name: Upload wheels | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: wheels-${{ matrix.target }} | |
# path: ${{ env.GITHUB_WORKSPACE }}/dist/* | |
# if-no-files-found: error | |
# windows: | |
# if: false | |
# runs-on: windows-latest | |
# strategy: | |
# matrix: | |
# target: [x64, x86] | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Setup Python | |
# uses: actions/setup-python@v4 | |
# with: | |
# python-version: '3.10' | |
# architecture: ${{ matrix.target }} | |
# - name: Build wheels | |
# uses: PyO3/maturin-action@v1 | |
# with: | |
# working-directory: src/pypgstac | |
# target: ${{ matrix.target }} | |
# args: --release --out ${{ env.GITHUB_WORKSPACE }}/dist | |
# sccache: 'true' | |
# - name: Upload wheels | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: win-wheels-${{ matrix.target }} | |
# path: ${{ env.GITHUB_WORKSPACE }}/dist/* | |
# if-no-files-found: error | |
# macos: | |
# if: false | |
# runs-on: macos-latest | |
# strategy: | |
# matrix: | |
# target: [x86_64, aarch64] | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Build wheels | |
# uses: PyO3/maturin-action@v1 | |
# with: | |
# working-directory: src/pypgstac | |
# target: ${{ matrix.target }} | |
# args: --release --out /tmp/dist | |
# sccache: 'true' | |
# - name: Upload wheels | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: mac-wheels-${{ matrix.target }} | |
# path: /tmp/dist/* | |
# if-no-files-found: error | |
# sdist: | |
# if: false | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Build sdist | |
# uses: PyO3/maturin-action@v1 | |
# with: | |
# working-directory: src/pypgstac | |
# command: sdist | |
# args: --out ${{ env.GITHUB_WORKSPACE }}/dist | |
# - name: Upload sdist | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: source-wheels | |
# path: ${{ env.GITHUB_WORKSPACE }}/dist/* | |
# if-no-files-found: error | |
# |