Skip to content

Commit

Permalink
ci: publish to github packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sastan committed Jan 1, 2021
1 parent b32024f commit 1c892b4
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 63 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: CI

on: [push]

jobs:
build:
name: Node ${{ matrix.node }} on ${{ matrix.os }}
Expand All @@ -8,7 +10,7 @@ jobs:
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
os: [ubuntu-18.04, macos-10.15, windows-2019]
os: [ubuntu-20.04, macos-10.15, windows-2019]

steps:
- name: Checkout 🛎️
Expand Down Expand Up @@ -41,9 +43,10 @@ jobs:
flag-name: build-${{ matrix.node }}-${{ matrix.os }}
parallel: true

finish:
coveralls:
name: Collect Coverage
needs: build
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/publish-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Publish PR

on: [pull_request]

jobs:
publish:
name: Publish to Github Packages
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2

- name: Use Node v14.x
uses: actions/setup-node@v1
with:
node-version: '14'

- name: Install 🔧
uses: bahmutov/npm-install@v1

- name: Build
run: yarn run build

- uses: actions/setup-node@v1
with:
registry-url: 'https://npm.pkg.github.com'

- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DIST_TAG="pr${{ github.event.number }}"
DIST_VERSION="0.0.0-${DIST_TAG}-${GITHUB_SHA:0:8}"
sed -i -r 's|("name": ")[^"]+(")|\1@${{ github.repository }}\2|;s|("version": ")[^"]+(")|\1@'$DIST_VERSION'\2|' dist/package.json
echo "> **THIS IS THE [PR ${{ github.event.number }}](${{ github.event.pull_request.html_url }}) PREVIEW PACKAGE**" > dist/README.md
echo "" >> dist/README.md
echo "---" >> dist/README.md
echo "" >> dist/README.md
cat README.md >> dist/README.md
npm publish --tag "${DIST_TAG}" --access public dist
- name: Comment
uses: mshick/add-pr-comment@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
allow-repeats: false # This is the default
message: |
> We publish PR packages to [npm.pkg.github.com](https://github.com/orgs/${{ github.repository_owner }}/packages?repo_name=twind).
> This allows to try new features before they are merged.
>
> Official releases are **only** available on [registry.npmjs.org](https://www.npmjs.com/package/twind) as `twind`.
**Install this PR package**
<details><summary>Configure your NPM client (click to expand)></summary>
Adjust you `.npmrc` to use `https://npm.pkg.github.com` for `@${{ github.repository_owner }}`
```
@${{ github.repository_owner }}:registry=https://npm.pkg.github.com
```
Using the command line:
```sh
npm config set @${{ github.repository_owner }}:registry https://npm.pkg.github.com --global
```
</details>
Install from command line:
```sh
# For npm
npm install twind@npm:@${{ github.repository }}@$pr{{ github.event.number }}
# For yarn
yarn add twind@npm:@${{ github.repository }}@pr${{ github.event.number }}
```
Install via package.json:
```json
{
"dependencies": {
"twind": "npm:@${{ github.repository }}@pr${{ github.event.number }}"
}
}
```
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
Expand Down
114 changes: 55 additions & 59 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
"Luke Jackson (lukejacksonn.github.io)",
"Sascha Tandel (https://github.com/sastan)"
],
"engines": {
"node": ">=10.13"
},
"// The 'module', 'unpkg' and 'types' fields are added by distilt": "",
"main": "src/index.ts",
"// Each entry is expanded twith several bundles (node, script, types and default)": "",
"// Each entry is expanded into several bundles (module, script, types, require, node, and default)": "",
"exports": {
".": "./src/index.ts",
"./colors": "./src/colors/index.ts",
Expand All @@ -34,10 +37,60 @@
"sideEffects": [
"./shim/shim.js"
],
"size-limit": [
{
"path": "dist/twind.js",
"gzip": true,
"limit": "11.5kb"
}
],
"// These are ONLY bundled (eg included) in the umd builds": "",
"bundledDependencies": [
"style-vendorizer"
],
"dependencies": {
"csstype": "^3.0.5",
"node-html-parser": "^2.0.1",
"style-vendorizer": "^2.0.0"
},
"peerDependencies": {
"typescript": "^4.1.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"devDependencies": {
"@size-limit/file": "^4.9.1",
"@types/jsdom": "^16.2.5",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"c8": "^7.3.5",
"distilt": "^0.9.0",
"dlv": "^1.1.3",
"doctoc": "^2.0.0",
"esbuild": "^0.8.23",
"esbuild-register": "^1.1.1",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.2.0",
"esm": "^3.2.25",
"execa": "^5.0.0",
"jsdom": "^16.4.0",
"prettier": "^2.0.5",
"size-limit": "^4.9.1",
"snoop": "^1.0.2",
"snowpack": "^2.18.2",
"tailwindcss": "^2.0.1",
"typescript": "^4.1.3",
"uvu": "^0.5.1",
"watchlist": "^0.2.3"
},
"// Tailwind requires Node v12, we support v10 => mark it as optional": "",
"optionalDependencies": {
"tailwindcss": "^2.0.1"
},
"scripts": {
"build": "distilt",
"preformat": "doctoc --update-only --notitle --maxlevel 3 docs/*.md",
Expand Down Expand Up @@ -98,62 +151,5 @@
]
}
]
},
"dependencies": {
"csstype": "^3.0.5",
"node-html-parser": "^2.0.1",
"style-vendorizer": "^2.0.0"
},
"peerDependencies": {
"typescript": "^4.1.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"devDependencies": {
"@size-limit/file": "^4.9.1",
"@types/jsdom": "^16.2.5",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"c8": "^7.3.5",
"distilt": "^0.9.0",
"dlv": "^1.1.3",
"doctoc": "^2.0.0",
"esbuild": "^0.8.23",
"esbuild-register": "^1.1.1",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.2.0",
"esm": "^3.2.25",
"execa": "^5.0.0",
"jsdom": "^16.4.0",
"prettier": "^2.0.5",
"size-limit": "^4.9.1",
"snoop": "^1.0.2",
"snowpack": "^2.18.2",
"tailwindcss": "^2.0.1",
"typescript": "^4.1.3",
"uvu": "^0.5.1",
"watchlist": "^0.2.3"
},
"// Tailwind requires Node v12, we support v10 => mark it as optional": "",
"optionalDependencies": {
"tailwindcss": "^2.0.1"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.com/"
},
"engines": {
"node": ">=10.13"
},
"size-limit": [
{
"path": "dist/twind.js",
"gzip": true,
"limit": "11.5kb"
}
]
}
}

0 comments on commit 1c892b4

Please sign in to comment.