Skip to content

Fix Validator ESM imports in some environments #9

Fix Validator ESM imports in some environments

Fix Validator ESM imports in some environments #9

# Copied from https://github.com/apollographql/apollo-client-nextjs/blob/9589d8105f40831d0e7a92130cbec12682d2671c/.github/workflows/snapshot-release.yml
# The MIT License (MIT)
#
# Copyright (c) 2023 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: Snapshot Release
on:
# eslint-disable-next-line yml/no-empty-mapping-value
workflow_dispatch:
issue_comment:
types:
- created
jobs:
publish:
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: write
pull-requests: write
if: |
github.repository == 'gekorm/better-auth-harmony' &&
(
github.event_name == 'workflow_dispatch' ||
(
github.event.issue.pull_request &&
(
github.event.sender.login == 'gekorm'
) &&
startsWith(github.event.comment.body, '/release:pr')
)
)
steps:
- uses: alessbell/[email protected]
if: github.event_name == 'issue_comment'
id: comment-branch
- name: Get sha
if: github.event_name == 'issue_comment'
id: parse-sha
continue-on-error: true
run: |
if [ "${{ steps.comment-branch.outputs.head_owner }}" == "gekorm" ]; then
echo "sha=${{ steps.comment-branch.outputs.head_sha }}" >> "${GITHUB_OUTPUT}"
else
sha_from_comment="$(echo $COMMENT_BODY | tr -s ' ' | cut -d ' ' -f2)"
if [ $sha_from_comment == "/release:pr" ]; then
exit 1
else
echo "sha=$sha_from_comment" >> "${GITHUB_OUTPUT}"
fi
fi
env:
COMMENT_BODY: ${{ github.event.comment.body }}
- name: Comment sha reminder
if: steps.parse-sha.outcome == 'failure'
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: |
Did you forget to add the sha? Please use `/release:pr <sha>`
- name: Fail job
if: steps.parse-sha.outcome == 'failure'
run: |
exit 1
- name: Checkout head ref (comment trigger)
if: github.event_name == 'issue_comment'
uses: actions/checkout@v4
with:
# # specify the owner + repository in order to checkout the fork
# # for community PRs
repository:
${{ steps.comment-branch.outputs.head_owner }}/${{
steps.comment-branch.outputs.head_repo }}
ref: ${{ steps.parse-sha.outputs.sha }}
fetch-depth: 0
- name: Checkout head ref (dispatch trigger)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
- name: Cache turbo setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: 22
- name: 📥 Monorepo install
uses: ./.github/actions/yarn-nm-install
with:
enable-corepack: true
cache-node-modules: true
cache-install-state: true
# 0.0.0 : to sort lower than any other release
# -commit-release : to sort higher than the already released 0.0.0-commit-<hash>,
# .0 : format specifier (if the following identifiers will change format, increase this number)
# .%ct : commit timestamp (to sort releases by commit date, not by hash)
# .%h : commit shorthash
- run:
echo PKG_VERSION="$(git show --no-patch --format=0.0.0-commit-release.0.%ct.%h)" >>
$GITHUB_ENV
- name: Build
run: yarn build
- name: 'better-auth-harmony: update version'
run: |
yarn workspace better-auth-harmony exec npm pkg set "version=${{ env.PKG_VERSION }}"
yarn workspace better-auth-harmony exec jq '{ version: .version, dependencies: .dependencies, peerDependencies: .peerDependencies }' package.json
- name: 'better-auth-harmony: publish'
run: yarn workspace better-auth-harmony exec npm publish --access public --tag snapshot
env:
NODE_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }}
- name: Create comment
if: github.event_name == 'issue_comment'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.issue.number }}
body: |
A new release has been made for this PR. You can install the package you need using
* `npm i better-auth-harmony@${{ env.PKG_VERSION }}`