Skip to content

Commit

Permalink
ci: automate publishing releases
Browse files Browse the repository at this point in the history
  • Loading branch information
vipero07 committed Dec 7, 2023
1 parent 2c88bee commit 17a0399
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Dependabot
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve and auto-merge a PR
run: |
gh pr merge --auto --squash "$PR_URL"
gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Package to npmjs
on:
release:
types: [published]
jobs:
npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
github:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
pull_request:
branches: [ main ]
types: [ closed ]

name: Create Release

permissions:
contents: write

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from package.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: 'jq .devDependencies.unocss package.json -r'
- name: Update package version in package.json
uses: sergeysova/jq-action@v2
with:
cmd: 'jq \'.version = "${{ steps.version.outputs.value }}"\' package.json'
- uses: actions4git/setup-git@v1
- run: |
git add package.json
git tag --force v${{ steps.version.outputs.value }}
git commit --message 'v${{ steps.version.outputs.value }}'
git push origin main --force
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.value }}
release_name: Release ${{ steps.version.outputs.value }}
body: |
Changes in this Release
- Unocss bumped to ${{ steps.version.outputs.value }}
draft: false
prerelease: false
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Scrollbar Preset for UnoCSS. Allows unocss utility classes to be used on scrollb
## Installation

```bash
pnpm add @unocss/preset-scrollbar -D
pnpm add unocss-scrollbar-variant -D
```

## Usage

```js
// unocss.config.js
import { defineConfig, presetUno } from 'unocss'
import { presetScrollbar } from '@unocss/preset-scrollbar'
import { presetScrollbar } from 'unocss-scrollbar-variant'

export default defineConfig({
presets: [
Expand Down

0 comments on commit 17a0399

Please sign in to comment.