Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing workflow updates #21

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/actions/setup-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Setup Dependencies"
runs:
using: "composite"
steps:
- run: corepack enable pnpm
shell: bash

- name: Setup Node.js LTS
uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
cache: pnpm

- name: Install Dependencies
run: pnpm install
shell: bash
33 changes: 3 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@ jobs:
steps:
- uses: actions/checkout@main

- name: Set Node.js 22.x
uses: actions/setup-node@main
with:
node-version: 22.x

- name: Install pnpm
run: corepack enable pnpm

- name: Install Dependencies
run: pnpm i
- uses: ./.github/actions/setup-deps

- name: Check Types
run: pnpm run types
Expand All @@ -32,16 +23,7 @@ jobs:
steps:
- uses: actions/checkout@main

- name: Set Node.js 22.x
uses: actions/setup-node@main
with:
node-version: 22.x

- name: Install pnpm
run: corepack enable pnpm

- name: Install Dependencies
run: pnpm i
- uses: ./.github/actions/setup-deps

- name: Linting
run: pnpm run lint
Expand All @@ -51,16 +33,7 @@ jobs:
steps:
- uses: actions/checkout@main

- name: Set Node.js 22.x
uses: actions/setup-node@main
with:
node-version: 22.x

- name: Install pnpm
run: corepack enable pnpm

- name: Install Dependencies
run: pnpm i
- uses: ./.github/actions/setup-deps

- name: Tests
run: pnpm run test
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish

on:
workflow_dispatch:

permissions:
contents: write
id-token: write

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0
persist-credentials: true # needed for git push

- uses: ./.github/actions/setup-deps

- run: pnpm build

- name: git config
run: |
git config --global user.name 'Thinkmill Release Bot'
git config --global user.email '[email protected]'

- name: npm publish, git tag
run: pnpm changeset publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true

- run: git push origin --follow-tags
45 changes: 45 additions & 0 deletions .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish (Snapshot)

on:
workflow_dispatch:

permissions:
contents: write
id-token: write

jobs:
publish_snapshot:
name: Publish (Snapshot)
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@main
with:
persist-credentials: true # needed for git push

- uses: ./.github/actions/setup-deps

- name: version packages
run: pnpm changeset version --snapshot ${{ inputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: git commit
run: |
git config --global user.name 'Thinkmill Release Bot'
git config --global user.email '[email protected]'
git commit -a -m 'snapshot release'

- run: pnpm build

- name: npm publish, git tag
run: pnpm changeset publish --tag test
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true

# reset, then push the dangling commit
- name: git push
run: |
git reset HEAD~1 --hard
git push origin --tags
29 changes: 9 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
name: Release
name: Version Packages

on:
push:
branches:
- main
workflow_dispatch:

jobs:
release:
name: Release
versioning:
name: Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@main
- uses: actions/checkout@main
with:
fetch-depth: 0
persist-credentials: false

- name: Set Node.js 22.x
uses: actions/setup-node@main
with:
node-version: 22.x

- name: Install pnpm
run: corepack enable pnpm

- name: Install Dependencies
run: pnpm i
- uses: ./.github/actions/setup-deps

- name: "Create Pull Request or Publish to npm"
uses: changesets/action@master
- uses: changesets/action@v1
with:
publish: pnpm run release
version: pnpm run version
version: pnpm run version-packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
},
"scripts": {
"postinstall": "preconstruct dev && manypkg check",
"release": "preconstruct build && changeset publish",
"version": "changeset version && pnpm i --frozen-lockfile=false",
"version-packages": "changeset version && pnpm i --frozen-lockfile=false",
"test": "jest",
"types": "tsc",
"lint": "eslint .",
Expand Down