generating changelog #480
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: Webitel UI release with docs | |
on: | |
push: | |
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 | |
release: | |
needs: [install_deps, test] | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# token: ${{ secrets.DLOHVINOV_CLASSIC_PAT }} | |
- name: Get previous tag | |
id: previoustag | |
uses: "WyriHaximus/github-action-get-previous-tag@v1" | |
- name: generate Release Changelog | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
writeToFile: false | |
reverseOrder: true | |
excludeTypes: build | |
token: ${{ github.token }} | |
fromTag: ${{ github.ref_name }} | |
toTag: ${{ steps.previoustag.outputs.tag }} | |
- name: get-npm-version | |
id: package-version | |
uses: martinbeentjes/[email protected] | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: "v${{ steps.package-version.outputs.current-version}}" | |
name: "@webitel/ui-sdk v${{ steps.package-version.outputs.current-version}}" | |
body: ${{ steps.changelog.outputs.changes }} | |
- name: Sleep for 10 seconds | |
run: sleep 10s | |
shell: bash | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get new tag | |
id: newtag | |
uses: "WyriHaximus/github-action-get-previous-tag@v1" | |
- name: update Release Changelog | |
id: update-changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
reverseOrder: true | |
excludeTypes: build | |
token: ${{ github.token }} | |
# fromTag: "v${{ steps.package-version.outputs.current-version}}" | |
fromTag: ${{ steps.newtag.outputs.tag }} | |
toTag: ${{ steps.previoustag.outputs.tag }} | |
- name: commit changelog | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: autoupdate changelog | |
file_pattern: 'CHANGELOG.md' | |
push_options: --force | |
publish: | |
needs: [release] | |
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 | |
registry-url: https://registry.npmjs.org | |
- name: Check publish status | |
id: check_publish | |
uses: tehpsalmist/npm-publish-status-action@v1 | |
- name: Publish release | |
id: publish_release | |
if: ${{ steps.check_publish.outputs.exists == '0' }} | |
# env: | |
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
echo "Publishing release, ${{ steps.check_publish.outputs.exists }}" | |
npm run build | |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | |
npm publish --access public | |
- name: Report publish status | |
if: ${{ steps.check_publish.outputs.exists == '1' }} | |
run: echo "Package already published" | |
build_docs: | |
needs: [release] | |
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: | |
- 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 | |