Skip to content

0.1.2

0.1.2 #9

Workflow file for this run

# Build and publish the documentation as well as the package to NPM and version bump each time a new release is published on Github, or a push is made to the develop branch.
name: Build
on:
push:
branches: [develop]
paths-ignore:
- '*.md'
- '**/*.md'
- 'package.json'
- 'package-lock.json'
release:
types:
- published
permissions: write-all
env:
DOCS_BASE_PATH: docs/omni-state
LOCAL_VERSION:
jobs:
build-and-release:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v3
with:
persist-credentials: true
fetch-depth: 0
token: ${{ secrets.PROTECTED_TOKEN }}
- name: Ensure branch up to date 🌿
# Only on branch pushes, not on tagged releases
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: |
git pull
- name: Use Node.js 16.x βœ”
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
always-auth: true
- name: Install Package Dependencies πŸ”—
run: |
npm ci
- name: Build Project πŸ”§
run: npm run build
- name: Run Tests πŸ”₯
run: npm run test
- name: Bump patch version for beta ☝
# Develop branch only
if: github.ref == 'refs/heads/develop'
run: |
node scripts/unique-version.mjs --tag "beta"
- name: Build Docs πŸ“
run: |
npm run docs
- name: Auto Commit Changes πŸ‘©β€πŸ’»
uses: stefanzweifel/git-auto-commit-action@v4
# Only on branch pushes, not on tagged releases
if: ${{ startsWith(github.ref, 'refs/heads/') }}
with:
commit_message: Updated docs
branch: ${{ env.GITHUB_REF_NAME }}
- name: Auto Commit Changes πŸ‘©β€πŸ’»
uses: stefanzweifel/git-auto-commit-action@v4
# Tagged release branch only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
commit_message: Updated docs
branch: main
push_options: '--force'
- name: Publish Beta Docs πŸš€
uses: JamesIves/github-pages-deploy-action@v4.3.4
# Develop branch only
if: github.ref == 'refs/heads/develop'
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: capitec/open-source
branch: main
folder: docs/api # The folder to grab the built docs files from
target-folder: ${{ env.DOCS_BASE_PATH }}/versions/beta # The folder to commit the build docs files into
clean: true # Clean out any previous files in the target folder
clean-exclude: |
versions
git-config-name: Deploy Bot
git-config-email: opensource@capitecbank.co.za
- name: Publish Version Docs πŸš€
uses: JamesIves/github-pages-deploy-action@v4.3.4
# Tagged release branch only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: capitec/open-source
branch: main
folder: docs/api # The folder to grab the built docs files from
target-folder: ${{ env.DOCS_BASE_PATH }}/versions/${{ github.event.release.tag_name }} # The folder to commit the build docs files into
clean: true
clean-exclude: |
versions
git-config-name: Deploy Bot
git-config-email: opensource@capitecbank.co.za
- name: Publish Latest Docs πŸš€
uses: JamesIves/github-pages-deploy-action@v4.3.4
# Release only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: capitec/open-source
branch: main
folder: docs/api # The folder to grab the built docs files from
target-folder: ${{ env.DOCS_BASE_PATH }} # The folder to commit the build docs files into
clean:
true
# Dont clean the versions directory when deploying to latest docs path
clean-exclude: |
versions
git-config-name: Deploy Bot
git-config-email: opensource@capitecbank.co.za
- name: Update LOCAL_VERSION ⬆
# Branches only, not releases
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: |
LOCAL_VERSION=$(cat package.json | jq -r .version | awk '{ print tolower($1) }')
echo LOCAL_VERSION=${LOCAL_VERSION} >> $GITHUB_ENV
- name: Publish Latest Package πŸ“¦
# Release only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
npm version "${{ github.event.release.tag_name }}" -git-tag-version false -allow-same-version true
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish Beta Package πŸ“¦
# Develop branch only
if: github.ref == 'refs/heads/develop'
run: |
npm version "${{ env.LOCAL_VERSION }}-beta" -git-tag-version false -allow-same-version true
npm publish --tag beta --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}