This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build from latest version, publish package and deploy docs to production" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
jobs: | |
release: | |
name: "Build" | |
if: github.repository == 'saadeghi/daisyui' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "latest" | |
# registry-url: https://registry.npmjs.org | |
- name: check latest released version | |
id: check | |
uses: EndBug/version-check@v2 | |
with: | |
file-url: https://unpkg.com/daisyui@latest/package.json | |
static-checking: localIsNew | |
- name: Install dependencies | |
if: steps.check.outputs.changed == 'true' | |
run: npm install | |
- name: build | |
if: steps.check.outputs.changed == 'true' | |
run: npm run build | |
- name: Publish | |
if: steps.check.outputs.changed == 'true' | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
- name: Read package version from package.json | |
if: steps.check.outputs.changed == 'true' | |
uses: nyaa8/package-version@v1 | |
with: | |
path: "package.json" | |
- name: update package version in env | |
if: steps.check.outputs.changed == 'true' | |
uses: SpicyPizza/create-envfile@v1 | |
with: | |
envkey_VITE_DAISYUI_VERSION: ${{ env.PACKAGE_VERSION }} | |
file_name: src/docs/.env | |
- name: update package version in readme | |
if: steps.check.outputs.changed == 'true' | |
uses: mingjun97/file-regex-replace@v1 | |
with: | |
regex: 'cdn.jsdelivr.net\/npm\/daisyui@.*\/dist\/' | |
replacement: "cdn.jsdelivr.net/npm/daisyui@${{ env.PACKAGE_VERSION }}/dist/" | |
include: "README.md" | |
- name: Commit files | |
if: steps.check.outputs.changed == 'true' | |
id: commit | |
run: | | |
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 "::set-output name=push::false" | |
else | |
git commit -m "Update version" -a | |
echo "::set-output name=push::true" | |
fi | |
shell: bash | |
- name: Push changes | |
if: steps.commit.outputs.push == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Wait 10 seconds for npm publish | |
if: steps.check.outputs.changed == 'true' | |
uses: whatnick/wait-action@master | |
with: | |
time: "10s" | |
- name: Install document website dependencies | |
run: cd src/docs && npm install | |
- name: Install latest daisyUI version | |
run: cd src/docs && npm i daisyui@latest | |
- name: get new data from API | |
run: cd src/docs && npm run get-files | |
- name: Build document website | |
run: cd src/docs && npm run build | |
- name: Deploy docs to github pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./src/docs/build | |
cname: ${{ secrets.CNAME }} |