Skip to content

Commit

Permalink
workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
saadeghi committed Nov 28, 2023
1 parent 277d835 commit 7bc6f37
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 21 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/deploy-docs.yml
Expand Up @@ -17,11 +17,6 @@ on:
paths:
- "src/docs/**"
- "CHANGELOG.md"
workflow_run:
workflows:
- "🎉 Release new version"
types:
- completed

jobs:
deploy-docs:
Expand Down
63 changes: 48 additions & 15 deletions .github/workflows/release-new-version.yml
Expand Up @@ -26,9 +26,10 @@ on:
- "!src/experiments/**"

jobs:
release:
timeout-minutes: 10
build:
name: 🔨 Build
if: github.repository == 'saadeghi/daisyui'
timeout-minutes: 10
runs-on: ubuntu-latest
env:
runtime: ${{ github.event.inputs.runtime || 'bun'}}
Expand All @@ -43,7 +44,7 @@ jobs:
node-version: "latest"
registry-url: https://registry.npmjs.org

- name: Setup bun
- name: Setup Bun
if: env.runtime == 'bun'
uses: oven-sh/setup-bun@v1

Expand All @@ -53,31 +54,30 @@ jobs:
- name: build package
run: ${{ env.runtime }} run build

- name: Release
- name: Run release command
run: |
git config --local user.email "pouya.saadeghi@gmail.com"
git config --local user.name "Pouya Saadeghi"
${{ env.runtime }} run release${{ github.event.inputs.release-type }}
- name: get-npm-version
- name: Read package version from package.json
id: package-version
run: |
echo current-version=$(grep -o '"version": *"[^"]*"' package.json | cut -d'"' -f4) >> $GITHUB_OUTPUT
version=$(grep -o '"version": *"[^"]*"' package.json | cut -d'"' -f4)
echo version=$version >> $GITHUB_OUTPUT
- name: update package version in env
run: echo "VITE_DAISYUI_VERSION=${{ steps.package-version.outputs.current-version }}" > src/docs/.env

- name: Commit files
- name: Update package version in src/docs/.env and commit
id: commit
run: |
echo "VITE_DAISYUI_VERSION=${{ steps.package-version.outputs.version }}" > src/docs/.env
git config --local user.email "pouya.saadeghi@gmail.com"
git config --local user.name "Pouya Saadeghi"
git add --all
if [-z "$(git status --porcelain)"]; then
echo "push=false" >> $GITHUB_OUTPUT
echo push=false >> $GITHUB_OUTPUT
else
git commit -m "Update version: ${{ steps.package-version.outputs.current-version }}" -a
echo "push=true" >> $GITHUB_OUTPUT
git commit -m "Update src/docs/.env" -a
echo push=true >> $GITHUB_OUTPUT
fi
shell: bash

Expand All @@ -87,14 +87,47 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
publish-npm:
name: 🚀 Publish to NPM
if: github.repository == 'saadeghi/daisyui'
timeout-minutes: 5
runs-on: ubuntu-latest
needs: build
env:
runtime: ${{ github.event.inputs.runtime || 'bun'}}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
if: env.runtime != 'npm'
uses: actions/setup-node@v3
with:
node-version: "latest"
registry-url: https://registry.npmjs.org

- name: Publish package
- name: Publish package to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

deploy-docs:
name: 📘 Docs
needs: publish-npm
uses: ./.github/workflows/deploy-docs.yml
secrets: inherit

run-tests:
name: 🧪 Tests
needs: publish-npm
uses: ./.github/workflows/run-tests.yml
secrets: inherit
with:
filter: " "

write-release-notes:
name: 📝 Release notes
if: github.repository == 'saadeghi/daisyui'
needs: run-tests
uses: ./.github/workflows/write-release-notes.yml
secrets: inherit
Expand Up @@ -14,6 +14,10 @@ on:
- "-t foreground"
- "-t variables"
- "-t colors"
workflow_call:
inputs:
filter:
type: string
push:
branches:
- master
Expand All @@ -27,7 +31,7 @@ jobs:
timeout-minutes: 10
env:
filter: ${{ github.event.inputs.filter || ' '}}
name: "Build"
name: "Tests"
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/write-release-notes.yml
@@ -0,0 +1,39 @@
name: "📝 write release notes"

on:
workflow_call:

jobs:
write-release-notes:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Read package version from package.json
id: package-version
run: |
version=$(grep -o '"version": *"[^"]*"' package.json | cut -d'"' -f4)
echo version=$version >> $GITHUB_OUTPUT
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo $version is a stable version
echo is-stable=true >> $GITHUB_OUTPUT
else
echo $version is not a stable version
fi
- name: Add release notes to GitHub
uses: softprops/action-gh-release@v1
if: steps.package-version.outputs.is-stable == 'true'
with:
tag_name: v${{ steps.package-version.outputs.version }}
body: |
🌼 Read changelog: https://daisyui.com/docs/changelog/
📦 Install this update:
```bash
npm i -D daisyui@${{ steps.package-version.outputs.version }}
```
💚 Thank you for using daisyUI!

0 comments on commit 7bc6f37

Please sign in to comment.