v0.0.42 #37
Workflow file for this run
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: Publish | |
permissions: {} | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
jobs: | |
publish-dbdev: | |
runs-on: macos-latest | |
outputs: | |
dbdev_version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- name: Get version | |
id: get_version | |
working-directory: ./extension | |
run: | | |
version=$(grep "default_version" keyhippo.control | sed "s/default_version[[:space:]]*=[[:space:]]*'//;s/'$//") | |
echo "version=$version" >> "$GITHUB_OUTPUT" | |
echo "Parsed version: $version" | |
- name: Build dbdev | |
run: nix build github:integrated-reasoning/nixpkgs/dbdev#dbdev | |
- name: Create dbdev login script | |
run: | | |
cat << 'EOF' > dbdev_login.sh | |
#!/usr/bin/env bash | |
set -e | |
if [ -z "${1}" ]; then | |
echo "Error: Token not provided" | |
exit 1 | |
fi | |
expect << EOD | |
set timeout 30 | |
spawn nix run github:integrated-reasoning/nixpkgs/dbdev#dbdev login | |
expect { | |
"Please paste the token" { | |
send "${1}\r" | |
exp_continue | |
} | |
timeout { | |
puts "Timed out waiting for token prompt" | |
exit 1 | |
} | |
eof | |
} | |
EOD | |
if [ $? -eq 0 ]; then | |
echo "Successfully logged in to database.dev" | |
else | |
echo "Failed to log in to database.dev" | |
exit 1 | |
fi | |
EOF | |
chmod +x dbdev_login.sh | |
- name: Login to database.dev | |
env: | |
DBDEV_TOKEN: ${{ secrets.DBDEV_TOKEN }} | |
run: ./dbdev_login.sh "$DBDEV_TOKEN" | |
- name: Publish to database.dev | |
working-directory: ./extension | |
run: nix run github:integrated-reasoning/nixpkgs/dbdev#dbdev publish | |
post-dbdev-publish-tests: | |
needs: publish-dbdev | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup-integration-tests | |
- name: Install dbdev and KeyHippo from dbdev | |
working-directory: ./ | |
run: | | |
cat << EOF > setup_commands.sql | |
create extension if not exists http with schema extensions; | |
create extension if not exists pg_tle; | |
drop extension if exists "supabase-dbdev"; | |
select pgtle.uninstall_extension_if_exists('supabase-dbdev'); | |
select | |
pgtle.install_extension( | |
'supabase-dbdev', | |
resp.contents ->> 'version', | |
'PostgreSQL package manager', | |
resp.contents ->> 'sql' | |
) | |
from http( | |
( | |
'GET', | |
'https://api.database.dev/rest/v1/' | |
|| 'package_versions?select=sql,version' | |
|| '&package_name=eq.supabase-dbdev' | |
|| '&order=version.desc' | |
|| '&limit=1', | |
array[ | |
('apiKey', '${{ secrets.DBDEV_ANON_API_KEY }}')::http_header | |
], | |
null, | |
null | |
) | |
) x, | |
lateral ( | |
select | |
((row_to_json(x) -> 'content') #>> '{}')::json -> 0 | |
) resp(contents); | |
create extension "supabase-dbdev"; | |
select dbdev.install('supabase-dbdev'); | |
drop extension if exists "supabase-dbdev"; | |
create extension "supabase-dbdev"; | |
select dbdev.install('keyhippo@keyhippo'); | |
create extension "keyhippo@keyhippo" version '${{ needs.publish-dbdev.outputs.dbdev_version }}'; | |
EOF | |
PGPASSWORD=postgres psql -h localhost -p 54322 -U postgres -d postgres -v ON_ERROR_STOP=1 -f setup_commands.sql | |
- uses: ./.github/actions/setup-environment | |
- name: Run tests | |
working-directory: ./ | |
run: nix develop --command make pg_tap |