chore(ci): Add promotion workflow #41
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: release | |
on: | |
push: | |
branches: | |
- main | |
- v5 | |
jobs: | |
call-build-lint-test-workflow: | |
uses: ./.github/workflows/build-lint-test.yml | |
build-typedocs: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: [call-build-lint-test-workflow] | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: '14' | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
name: Cache npm deps | |
with: | |
path: | | |
node_modules | |
**/node_modules | |
~/.cache/Cypress | |
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }} | |
- run: yarn install --frozen-lockfile | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
- uses: actions/cache@v2 | |
id: css-in-js-cache | |
name: Cache css in js files | |
with: | |
path: | | |
packages/module/src/css | |
key: ${{ runner.os }}-css-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('packages/module/src/css/*') }} | |
- name: generate | |
run: cd packages/module && yarn generate | |
if: steps.css-in-js-cache.outputs.cache-hit != 'true' | |
- uses: actions/cache@v2 | |
id: dist | |
name: Cache dist | |
with: | |
path: | | |
packages/*/dist | |
key: ${{ runner.os }}-dist-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock', 'package.json', 'packages/*/*', '!packages/*/dist', '!packages/*/node_modules') }} | |
- name: Build dist | |
run: yarn build | |
if: steps.dist.outputs.cache-hit != 'true' | |
- name: Build typedocs | |
run: yarn build:typedocs | |
- name: Archive artifact | |
shell: sh | |
run: | | |
chmod -c -R +rX "$INPUT_PATH" | while read line; do | |
echo "::warning title=Invalid file permissions automatically fixed::$line" | |
done | |
tar \ | |
--dereference --hard-dereference \ | |
--directory "$INPUT_PATH" \ | |
-cvf "$RUNNER_TEMP/artifact.tar" \ | |
--exclude=.git \ | |
--exclude=.github \ | |
. | |
env: | |
INPUT_PATH: docs | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: github-pages | |
path: ${{ runner.temp }}/artifact.tar | |
retention-days: 1 | |
if-no-files-found: error | |
deploy-typedocs: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: [call-build-lint-test-workflow, build-typedocs] | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
deploy-package: | |
runs-on: ubuntu-latest | |
needs: [call-build-lint-test-workflow] | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: '14' | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
name: Cache npm deps | |
with: | |
path: | | |
node_modules | |
**/node_modules | |
~/.cache/Cypress | |
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }} | |
- run: yarn install --frozen-lockfile | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
- uses: actions/cache@v2 | |
id: css-in-js-cache | |
name: Cache css in js files | |
with: | |
path: | | |
packages/module/src/css | |
key: ${{ runner.os }}-css-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('packages/module/src/css/*') }} | |
- name: generate | |
run: cd packages/module && yarn generate | |
if: steps.css-in-js-cache.outputs.cache-hit != 'true' | |
- uses: actions/cache@v2 | |
id: dist | |
name: Cache dist | |
with: | |
path: | | |
packages/*/dist | |
key: ${{ runner.os }}-dist-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock', 'package.json', 'packages/*/*', '!packages/*/dist', '!packages/*/node_modules') }} | |
- name: Build dist | |
run: yarn build | |
if: steps.dist.outputs.cache-hit != 'true' | |
- name: Release to NPM | |
run: cd packages/module && npx [email protected] |