Skip to content

Commit f84d0af

Browse files
authored
chore(cicd): Create release workflow following #366 discussion proposal 1 (#369)
1 parent 6c19444 commit f84d0af

File tree

3 files changed

+94
-23
lines changed

3 files changed

+94
-23
lines changed

Diff for: .github/workflows/on-merge-to-main.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
uses: actions/[email protected]
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

Diff for: .github/workflows/on-release.yml renamed to .github/workflows/on-release-prod.yml

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: release
22
on:
3-
push:
4-
branches:
5-
- main
63
workflow_dispatch: {}
74
jobs:
85
publish:
@@ -44,12 +41,7 @@ jobs:
4441
git config --global user.name 'github-actions[bot]'
4542
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
4643
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY
47-
48-
if [ ${{ github.base_ref }} = main ]; then
49-
npx lerna version --conventional-commits --create-release github --force-publish=* --yes
50-
else
51-
npx lerna version --conventional-commits --conventional-prerelease --preid beta --create-release github --force-publish=* --yes
52-
fi
44+
npx lerna version --conventional-commits --conventional-graduate --force-publish=* --yes
5345
npx lerna publish from-git --no-verify-access --yes
5446
#########################
5547
# Generate documentation

Diff for: .github/workflows/release-drafter.yml

-14
This file was deleted.

0 commit comments

Comments
 (0)