Relation Queries #674
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: 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-zod | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
registry-url: 'https://registry.npmjs.org' | |
- uses: pnpm/action-setup@v2 | |
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)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
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: Build (for fork PRs only) | |
if: github.event_name == 'pull_request' | |
run: | | |
pnpm build --filter ${{ matrix.package }} | |
- name: Build & publish | |
if: github.event_name == 'push' | |
run: | | |
tag="${{ github.ref_name }}" | |
old_version="$(jq -r .version package.json)" | |
version="$old_version-$(git rev-parse --short HEAD)" | |
is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')" | |
if [[ "$is_version_published" == "true" ]]; then | |
echo "Version $version already published, adding tag $tag" | |
npm dist-tag add ${{ matrix.package }}@$version $tag | |
else | |
echo "Publishing ${{ matrix.package }}@$tag using version $version" | |
npm version $version | |
(cd .. && npm run pack -- --filter ${{ matrix.package }}) | |
npm run publish -- --tag $tag | |
fi | |
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 }} |