Skip to content

Commit

Permalink
ci: add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzkirstein committed Mar 14, 2024
1 parent 7eda92a commit 16bbdcf
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release (Canary)
on:
push:
branches: [main, feat/build]
workflow_dispatch:

jobs:
canary:
name: Release canary
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Setup .npmrc file
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'

- name: Set version
run: |
jq --arg prop "workspaces" 'del(.[$prop])' package.json > package.tmp.json && rm package.json && cp package.tmp.json package.json && rm package.tmp.json
cd src
npm --no-git-tag-version version 0.0.0
npm --no-git-tag-version version $(npm pkg get version | sed 's/"//g')-$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//').$(date +'%Y%m%dT%H%M%S')
- name: Build
run: npm run build

- name: Publish to npm
run: cd src && npm publish --tag $(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Changesets
on:
push:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Verify
uses: ./.github/workflows/verify.yml
secrets: inherit

changesets:
name: Create version pull request
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Create Version Pull Request
uses: changesets/action@v1
with:
commit: 'chore: version package'
title: 'chore: version package'
version: npm run changeset:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
id-token: write

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Publish to NPM
uses: changesets/action@v1
with:
createGithubReleases: ${{ github.ref == 'refs/heads/main' }}
publish: npm run changeset:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# https://docs.npmjs.com/generating-provenance-statements
NPM_CONFIG_PROVENANCE: true
90 changes: 90 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Verify
on:
workflow_call:
workflow_dispatch:

jobs:
# lint:
# name: Lint
# runs-on: ubuntu-latest
# timeout-minutes: 5

# steps:
# - name: Clone repository
# uses: actions/checkout@v4

# - name: Install dependencies
# uses: ./.github/actions/install-dependencies

# - name: Lint code
# run: npm format && bun lint:fix

# - uses: stefanzweifel/git-auto-commit-action@v5
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# commit_message: 'chore: format'
# commit_user_name: 'github-actions[bot]'
# commit_user_email: 'github-actions[bot]@users.noreply.github.com'

build:
name: Build
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Build
run: npm run build

types:
name: Types
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
typescript-version: ['5.0.2', 'latest']

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- run: npm i -D typescript@${{ matrix.typescript-version }}

- name: Check types
run: npm run typecheck

# test:
# name: Test
# runs-on: ubuntu-latest
# timeout-minutes: 10
# steps:
# - name: Clone repository
# uses: actions/checkout@v4

# - name: Install dependencies
# uses: ./.github/actions/install-dependencies

# - name: Run tests
# uses: nick-fields/retry@v3
# with:
# timeout_minutes: 10
# max_attempts: 3
# command: npm run test
# env:
# SOME_ENV: ${{ vars.SOME_ENV }}

# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 16bbdcf

Please sign in to comment.