Update action path #51
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: ci | |
on: | |
pull_request: | |
push: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup requirements | |
uses: .github/setup | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Lint library | |
working-directory: packages/typeschema | |
run: pnpm lint | |
- name: Test library | |
working-directory: packages/typeschema | |
run: pnpm test | |
- name: Build library | |
working-directory: packages/typeschema | |
run: pnpm build | |
- name: Create package | |
id: pack | |
working-directory: packages/typeschema | |
run: | | |
pnpm pack | |
echo "tar=$(find -name '*.tgz')" >> $GITHUB_OUTPUT | |
cp *.tgz ../.. | |
- name: Lint package | |
working-directory: packages/typeschema | |
run: pnpm lint:package | |
- name: Upload package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: npm-package-typeschema | |
path: ${{steps.pack.outputs.tar}} | |
bundle_with_vite: | |
needs: build | |
name: Test bundling with Vite | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup requirements | |
uses: .github/setup | |
- name: Create a Vite project | |
run: pnpm create vite sample --template vanilla-ts | |
- name: Download package | |
uses: actions/download-artifact@v3 | |
with: | |
name: npm-package-typeschema | |
- name: Add package | |
working-directory: sample | |
run: pnpm install $(ls ../decs-typeschema-*.tgz) zod | |
- name: Use package | |
working-directory: sample | |
run: | | |
echo " | |
import {validate} from '@decs/typeschema'; | |
import {z} from 'zod'; | |
validate(z.string(), 'hello').then(console.log); | |
" > src/main.ts | |
- name: Bundle project | |
working-directory: sample | |
run: pnpm build | |
bundle_with_webpack: | |
needs: build | |
name: Test bundling with Webpack | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup requirements | |
uses: .github/setup | |
- name: Create a Next.js project | |
run: pnpm create next-app sample --ts --eslint --tailwind --src-dir --app --import-alias="@/*" | |
- name: Download package | |
uses: actions/download-artifact@v3 | |
with: | |
name: npm-package-typeschema | |
- name: Add package | |
working-directory: sample | |
run: pnpm install $(ls ../decs-typeschema-*.tgz) zod | |
- name: Use package | |
working-directory: sample | |
run: | | |
echo " | |
import {validate} from '@decs/typeschema'; | |
import {z} from 'zod'; | |
export default function Page() { | |
validate(z.string(), 'hello').then(console.log); | |
} | |
" > src/app/page.tsx | |
- name: Bundle project | |
working-directory: sample | |
run: pnpm build | |
bundle_with_turbopack: | |
needs: build | |
name: Test bundling with Turbopack | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup requirements | |
uses: .github/setup | |
- name: Create a Next.js project | |
run: pnpm create next-app sample --ts --eslint --tailwind --src-dir --app --import-alias="@/*" | |
- name: Download package | |
uses: actions/download-artifact@v3 | |
with: | |
name: npm-package-typeschema | |
- name: Add package | |
working-directory: sample | |
run: pnpm install $(ls ../decs-typeschema-*.tgz) zod | |
- name: Use package | |
working-directory: sample | |
run: | | |
echo " | |
import {validate} from '@decs/typeschema'; | |
import {z} from 'zod'; | |
export default function Page() { | |
validate(z.string(), 'hello').then(console.log); | |
} | |
" > src/app/page.tsx | |
- name: Start development server | |
working-directory: sample | |
run: pnpm next dev --turbo & | |
- name: Load page | |
working-directory: sample | |
run: curl http://127.0.0.1:3000 -f | |
check_for_version_upgrade: | |
name: Check for version upgrade | |
if: | | |
github.event_name == 'push' || | |
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login | |
runs-on: ubuntu-latest | |
needs: [bundle_with_vite, bundle_with_webpack, bundle_with_turbopack] | |
outputs: | |
from_version: ${{steps.check.outputs.from_version}} | |
to_version: ${{steps.check.outputs.to_version}} | |
is_upgraded_version: ${{steps.check.outputs.is_upgraded_version}} | |
is_pre_release: ${{steps.check.outputs.is_pre_release}} | |
steps: | |
- uses: garronej/ts-ci@v2.1.0 | |
id: check | |
with: | |
action_name: is_package_json_version_upgraded | |
branch: ${{github.head_ref || github.ref}} | |
publish_to_deno: | |
name: Publish to Deno | |
runs-on: ubuntu-latest | |
needs: check_for_version_upgrade | |
if: | | |
needs.check_for_version_upgrade.outputs.is_upgraded_version == 'true' && | |
( | |
github.event_name == 'push' || | |
needs.check_for_version_upgrade.outputs.is_pre_release == 'true' | |
) | |
steps: | |
- name: Setup requirements | |
uses: .github/setup | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Skip GitHub actions | |
run: rm -r .github | |
- name: Remove deno-dist branch if it exists | |
run: git push origin :deno-dist || true | |
- name: Checkout deno-dist branch | |
run: git checkout -b deno-dist | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build library | |
run: pnpm build:deno | |
- name: Track deno_dist folder | |
run: npx -y -p denoify remove_deno_dist_from_gitignore | |
env: | |
DRY_RUN: '0' | |
- name: Push changes | |
run: | | |
git config --global user.name actions | |
git config --global user.email actions@github.com | |
git add -A | |
git commit -am "Add deno distribution files" | |
git push origin deno-dist | |
- name: Create release on GitHub | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: v${{needs.check_for_version_upgrade.outputs.to_version}} | |
tag_name: v${{needs.check_for_version_upgrade.outputs.to_version}} | |
target_commitish: deno-dist | |
generate_release_notes: false | |
draft: false | |
prerelease: ${{needs.check_for_version_upgrade.outputs.is_pre_release == 'true'}} | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- name: Remove deno-dist branch | |
run: git push origin :deno-dist | |
publish_to_npm: | |
name: Publish to NPM | |
runs-on: ubuntu-latest | |
needs: check_for_version_upgrade | |
if: | | |
needs.check_for_version_upgrade.outputs.is_upgraded_version == 'true' && | |
( | |
github.event_name == 'push' || | |
needs.check_for_version_upgrade.outputs.is_pre_release == 'true' | |
) | |
steps: | |
- name: Setup requirements | |
uses: .github/setup | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build library | |
working-directory: packages/typeschema | |
run: pnpm build | |
- name: Publish library to NPM | |
uses: JS-DevTools/npm-publish@v2 | |
with: | |
token: ${{secrets.NPM_TOKEN}} |