|
| 1 | +name: on-merge-to-main |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + workflow_dispatch: {} |
| 7 | +jobs: |
| 8 | + publish: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + steps: |
| 12 | + - name: "Checkout" |
| 13 | + uses: actions/checkout@v2 |
| 14 | + with: |
| 15 | + token: ${{ secrets.GH_PUBLISH_TOKEN }} |
| 16 | + fetch-depth: 0 |
| 17 | + ######################### |
| 18 | + # Release new version |
| 19 | + ######################### |
| 20 | + - name: "Use NodeJS 14" |
| 21 | + uses: actions/setup-node@v2 |
| 22 | + with: |
| 23 | + node-version: '14' |
| 24 | + - name: "Setup npm" |
| 25 | + run: | |
| 26 | + npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" |
| 27 | + - name: Install packages |
| 28 | + run: | |
| 29 | + npm ci |
| 30 | + npm run lerna-ci |
| 31 | + - name: Run lint |
| 32 | + run: npm run lerna-lint |
| 33 | + - name: Run tests |
| 34 | + run: npm run lerna-test |
| 35 | + - name: "Version and publish" |
| 36 | + env: |
| 37 | + GH_TOKEN: ${{ secrets.GH_PUBLISH_TOKEN }} |
| 38 | + run: | |
| 39 | + git config --global user.name 'github-actions[bot]' |
| 40 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 41 | + git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY |
| 42 | +
|
| 43 | + # For merge to main we |
| 44 | + ## don't create github release, |
| 45 | + ## don't update changelog (--no-changelog) |
| 46 | + ## bump version as a pre-release (--conventional-prerelease) |
| 47 | + ## add a custom preid (--preid dev): 0.2.0-dev.1 -> 0.2.0-dev.2 |
| 48 | + npx lerna version --conventional-commits --conventional-prerelease --preid dev --force-publish=* --yes --no-changelog |
| 49 | + git push --delete origin $(git describe --abbrev=0) |
| 50 | + - name: update_release_draft: |
| 51 | + uses: release-drafter/[email protected] |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + ######################### |
| 55 | + # Generate documentation |
| 56 | + ######################### |
| 57 | + - name: Set up Python |
| 58 | + |
| 59 | + with: |
| 60 | + python-version: '3.8' |
| 61 | + - name: Install doc generation dependencies |
| 62 | + run: | |
| 63 | + pip install --upgrade pip |
| 64 | + pip install -r docs/requirements.txt |
| 65 | + - name: Setup doc deploy |
| 66 | + run: | |
| 67 | + git config --global user.name Docs deploy |
| 68 | + git config --global user.email [email protected] |
| 69 | + - name: Build mkdocs site in "gh-pages" branch and push |
| 70 | + run: | |
| 71 | + rm -rf site |
| 72 | + VERSION="dev" |
| 73 | + echo "Publishing doc for version: $VERSION" |
| 74 | + mkdocs build |
| 75 | + mike deploy --push "$VERSION" |
| 76 | + - name: Build API docs |
| 77 | + run: | |
| 78 | + rm -rf api |
| 79 | + npm run docs-generateApiDoc |
| 80 | + - name: Release API docs to the released version |
| 81 | + uses: peaceiris/actions-gh-pages@v3 |
| 82 | + with: |
| 83 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + publish_dir: ./api |
| 85 | + keep_files: true |
| 86 | + destination_dir: dev/api |
| 87 | + - name: Release API docs to the "latest" version |
| 88 | + uses: peaceiris/actions-gh-pages@v3 |
| 89 | + with: |
| 90 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + publish_dir: ./api |
| 92 | + keep_files: true |
| 93 | + destination_dir: latest/api |
0 commit comments