Skip to content

Commit

Permalink
feat: docs, + changelog file, + updated github workflows to make rele…
Browse files Browse the repository at this point in the history
…ases and generate changelogs [WTEL-5425](https://webitel.atlassian.net/browse/WTEL-4325)
  • Loading branch information
dlohvinov committed Nov 4, 2024
1 parent 7cb9ec7 commit c40bfa6
Show file tree
Hide file tree
Showing 25 changed files with 5,391 additions and 3,845 deletions.
93 changes: 83 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,93 @@
name: Workspace CI
# NOTES:
# generating changelog for release is performed twice because first changelog generates for release notes,
# so it runs before release step, and second changelog generates for updating CHANGELOG.md file, so it runs after release step.
# if i'd try to generate changelog once, changes will be marked as "master" branch changes, cause there's no new tag yet.

name: webitel workspace tests and docs

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
install_deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cache node_modules
uses: actions/cache@v4
id: cache_node_modules
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
if: steps.cache_node_modules.outputs.cache-hit != 'true'
run: npm ci

test:
needs: [install_deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- run: npm run test:unit

build_docs:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build docs
run: npm run docs:build

- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
name: docs
path: docs/.vitepress/dist

deploy:
needs: [build_docs]
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- run: npm ci
- run: npm run test:unit
- name: setup Github Pages
id: setup_pages
uses: actions/configure-pages@v4

- name: deploy to Github Pages
id: deploy_pages
uses: actions/deploy-pages@v4
with:
artifact_name: docs

190 changes: 190 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# NOTES:
# generating changelog for release is performed twice because first changelog generates for release notes,
# so it runs before release step, and second changelog generates for updating CHANGELOG.md file, so it runs after release step.
# if i'd try to generate changelog once, changes will be marked as "master" branch changes, cause there's no new tag yet.

name: webitel workspace release

on:
push:
branches: [ release ]

jobs:
install_deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cache node_modules
uses: actions/cache@v4
id: cache_node_modules
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
if: steps.cache_node_modules.outputs.cache-hit != 'true'
run: npm ci

test:
needs: [install_deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- run: npm run test:unit

release:
needs: [install_deps, test]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: get prevTag
id: prevTag
uses: "WyriHaximus/github-action-get-previous-tag@v1"

# for release notes // why 2 changelogs? see NOTES
- name: generate Release Changelog
id: changelog
uses: requarks/changelog-action@v1
continue-on-error: true
with:
writeToFile: false
reverseOrder: true
excludeTypes:
token: ${{ github.token }}
fromTag: ${{ github.ref_name }}
toTag: ${{ steps.prevTag.outputs.tag }}

- name: get-npm-version
id: package-version
uses: martinbeentjes/[email protected]

- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ steps.package-version.outputs.current-version}}"
name: "@webitel/client v${{ steps.package-version.outputs.current-version}}"
body: ${{ steps.changelog.outputs.changes }}

# update tags list after prev step release, so that we fetch new tag, created by prev step
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: get newTag
id: newTag
uses: "WyriHaximus/github-action-get-previous-tag@v1"

# update CHANGELOG.md file // why 2 changelogs? see NOTES
- name: update Release Changelog
id: update-changelog
uses: requarks/changelog-action@v1
continue-on-error: true
with:
reverseOrder: true
excludeTypes: build
token: ${{ github.token }}
fromTag: ${{ steps.newTag.outputs.tag }}
toTag: ${{ steps.prevTag.outputs.tag }}

- name: commit changelog to release
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: release
commit_message: autoupdate changelog
file_pattern: 'CHANGELOG.md'
push_options: --force

- name: upload changelog artifact
uses: actions/upload-artifact@v4
with:
name: updated_changelog
path: ./CHANGELOG.md

update_master_changelog:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master

- name: download changelog artifact
uses: actions/download-artifact@v4
with:
name: updated_changelog

- name: commit changelog to master
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
commit_message: autoupdate changelog
file_pattern: 'CHANGELOG.md'
push_options: --force

build_docs:
needs: [update_master_changelog]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master

- uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build docs
run: npm run docs:build

- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
name: docs
path: docs/.vitepress/dist

deploy:
needs: [build_docs]
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
runs-on: ubuntu-latest
steps:
- name: setup Github Pages
id: setup_pages
uses: actions/configure-pages@v4

- name: deploy to Github Pages
id: deploy_pages
uses: actions/deploy-pages@v4
with:
artifact_name: docs

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.DS_Store
node_modules
/dist
/dev-dist
/coverage
demo.html
/docs/.vitepress/dist
/docs/.vitepress/cache

# local env files
.env.local
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world!
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
# cc-workspaces

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn serve
```

### Compiles and minifies for production
```
yarn build
```

### Run your unit tests
```
yarn test:unit
```

### Lints and fixes files
```
yarn lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
Loading

0 comments on commit c40bfa6

Please sign in to comment.