Build and deploy #26
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: Build and deploy | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag version to deploy (e.g., v1.2.3 or 1.2.3)" | |
| required: true | |
| type: string | |
| workflow_call: | |
| inputs: | |
| tag: | |
| description: "Tag version to deploy" | |
| required: true | |
| type: string | |
| permissions: | |
| id-token: write | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| env: | |
| NODE_VERSION: 22 | |
| steps: | |
| - name: Сheckout repo | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linter | |
| run: npm run lint | |
| - name: Run builder | |
| run: npm run build | |
| - name: Archiving lib directory | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lib | |
| path: ${{ github.workspace }}/lib | |
| retention-days: 1 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: [build] | |
| env: | |
| NODE_VERSION: 22 | |
| steps: | |
| - name: Сheckout repo | |
| uses: actions/checkout@v4 | |
| - name: Unarchiving lib directory | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: lib | |
| path: ${{ github.workspace }}/lib | |
| - name: Use Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| - name: Install modules | |
| run: npm ci | |
| - name: Set RELEASE_VERSION env | |
| run: | | |
| if [ -n "${{ inputs.tag }}" ]; then | |
| RELEASE_VERSION="${{ inputs.tag }}" | |
| else | |
| RELEASE_VERSION="${GITHUB_REF#refs/*/}" | |
| fi | |
| echo "RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ env.RELEASE_VERSION }} | |
| release_name: Release v${{ env.RELEASE_VERSION }} | |
| body: | | |
| see [CHANGELOG.md](https://github.com/siarheidudko/firebase-engine/blob/master/CHANGELOG.md) | |
| draft: false | |
| prerelease: false | |
| - name: Publish package to NPM | |
| run: npm publish |