Functionly build and publish #21
This file contains hidden or 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: Functionly build and publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: Version type publish | |
| required: true | |
| default: patch | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| dev: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: write # Required for pushing tags | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| cache-dependency-path: false | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Auto Increment Version, and Publish to npmjs | |
| run: | | |
| git config --global user.email "jaystack-ci@jaystack.com" | |
| git config --global user.name "jaystack-ci" | |
| git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
| npm version ${{ inputs.version_type }} -m "Auto-increment version: %s" --force | |
| npm publish --tag dev --provenance | |
| - name: Git operations | |
| run: | | |
| git tag -f dev | |
| git push -f --tags | |
| git push | |
| stage: | |
| needs: dev | |
| runs-on: ubuntu-latest | |
| environment: stage | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: write # Required for pushing tags | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: "refs/tags/dev" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: "24" | |
| - name: Extract package version | |
| id: package_version | |
| run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Create and push git tag | |
| run: | | |
| git tag -f stage | |
| git push -f --tags | |
| - name: Publish to npm | |
| run: npm dist-tag add functionly@${{ steps.package_version.outputs.VERSION }} stage | |
| live: | |
| needs: stage | |
| runs-on: ubuntu-latest | |
| environment: live | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: write # Required for pushing tags | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: "refs/tags/stage" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: "24" | |
| - name: Extract package version | |
| id: package_version | |
| run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Create and push git tag | |
| run: | | |
| git tag -f latest | |
| git push -f --tags | |
| - name: Publish to npm | |
| run: npm dist-tag add functionly@${{ steps.package_version.outputs.VERSION }} latest |