Merge pull request #8 from capitec/feature/fix-stores-export #10
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
# 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 }} |