Skip to content

Add an easier way to alias a column within a query #298

Add an easier way to alias a column within a query

Add an easier way to alias a column within a query #298

name: Release (feature branch)
on:
push:
branches-ignore:
- main
pull_request: {}
jobs:
release:
# only run on all pushes or pull requests from forks
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
package:
- drizzle-orm
- drizzle-kit
- drizzle-zod
- drizzle-seed
- drizzle-typebox
- drizzle-valibot
- eslint-plugin-drizzle
runs-on: ubuntu-20.04
permissions:
contents: read
id-token: write
services:
postgres-postgis:
image: postgis/postgis:16-3.4
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: drizzle
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 54322:5432
postgres-vector:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: drizzle
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 54321:5432
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: drizzle
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 55433:5432
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: drizzle
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 33306:3306
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.18'
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v3
name: Install pnpm
id: pnpm-install
with:
version: latest
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Check preconditions
id: checks
shell: bash
working-directory: ${{ matrix.package }}
run: |
old_version="$(jq -r .version package.json)"
version="$old_version-$(git rev-parse --short HEAD)"
npm version $version
tag="${{ github.ref_name }}"
is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')"
if [[ "$is_version_published" == "true" ]]; then
echo "\`${{ matrix.package }}$version\` already published, adding tag \`$tag\`" >> $GITHUB_STEP_SUMMARY
npm dist-tag add ${{ matrix.package }}@$version $tag
else
{
echo "version=$version"
echo "tag=$tag"
echo "has_new_release=true"
} >> $GITHUB_OUTPUT
fi
- name: Build
if: steps.checks.outputs.has_new_release == 'true'
run: |
(
cd drizzle-orm
pnpm prisma generate --schema src/prisma/schema.prisma
)
pnpm build
- name: Run tests
if: steps.checks.outputs.has_new_release == 'true'
env:
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:55433/drizzle
PG_VECTOR_CONNECTION_STRING: postgres://postgres:postgres@localhost:54321/drizzle
PG_POSTGIS_CONNECTION_STRING: postgres://postgres:postgres@localhost:54322/drizzle
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:33306/drizzle
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
XATA_API_KEY: ${{ secrets.XATA_API_KEY }}
XATA_BRANCH: ${{ secrets.XATA_BRANCH }}
LIBSQL_URL: file:local.db
LIBSQL_REMOTE_URL: ${{ secrets.LIBSQL_REMOTE_URL }}
LIBSQL_REMOTE_TOKEN: ${{ secrets.LIBSQL_REMOTE_TOKEN }}
run: |
if [[ ${{ github.event_name }} != "push" && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
export SKIP_EXTERNAL_DB_TESTS=1
fi
if [[ "${{ matrix.package }}" == "drizzle-orm" ]]; then
pnpm test --filter ${{ matrix.package }} --filter integration-tests
else
pnpm test --filter ${{ matrix.package }}
fi
- name: Pack
if: steps.checks.outputs.has_new_release == 'true'
working-directory: ${{ matrix.package }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
run: |
npm run pack
- name: Run @arethetypeswrong/cli
if: steps.checks.outputs.has_new_release == 'true'
working-directory: ${{ matrix.package }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
run: |
pnpm attw package.tgz
- name: Publish
if: github.event_name == 'push' && steps.checks.outputs.has_new_release == 'true'
run: |
tag="${{ steps.checks.outputs.tag }}"
version="${{ steps.checks.outputs.version }}"
echo "Publishing ${{ matrix.package }}@$tag using version $version"
npm run publish -- --tag $tag
echo "npm: \`${{ matrix.package }}@$tag | ${{ matrix.package }}@$version\`" >> $GITHUB_STEP_SUMMARY
# Post release message to Discord
# curl -X POST -H "Content-Type: application/json" -d "{\"embeds\": [{\"title\": \"New \`${{ matrix.package }}\` release! 🎉\", \"url\": \"https://www.npmjs.com/package/${{ matrix.package }}/v/$version\", \"color\": \"12907856\", \"fields\": [{\"name\": \"Version\", \"value\": \"\`$version\`\"}, {\"name\": \"Tag\", \"value\": \"\`$tag\`\"}]}]}" ${{ secrets.DISCORD_DEV_RELEASE_WEBHOOK_URL }}
working-directory: ${{ matrix.package }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}