api-client #6
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: api-client | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., 1.2.3)' | |
| required: true | |
| type: string | |
| jobs: | |
| build-and-publish: | |
| name: Build and publish @hopps/api-client | |
| runs-on: ubuntu-latest | |
| container: | |
| image: node:20 | |
| permissions: | |
| contents: write | |
| defaults: | |
| run: | |
| shell: bash | |
| working-directory: frontend/api-client | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install .NET SDK | |
| run: | | |
| apt-get update | |
| apt-get install -y wget apt-transport-https | |
| wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb | |
| dpkg -i packages-microsoft-prod.deb | |
| apt-get update | |
| apt-get install -y dotnet-sdk-8.0 | |
| dotnet --info | |
| - name: Setup pnpm | |
| run: | | |
| corepack enable | |
| corepack prepare pnpm@latest --activate | |
| pnpm -v | |
| - name: Set package version from input | |
| run: | | |
| pnpm version "${{ inputs.version }}" --no-git-tag-version | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Generate Org Service client (NSwag) | |
| run: pnpm run generate:org-service | |
| - name: Build package | |
| run: pnpm run build | |
| # - name: Commit and push generated OrgService changes | |
| # if: startsWith(github.ref, 'refs/heads/') | |
| # env: | |
| # BRANCH_NAME: ${{ github.ref_name }} | |
| # run: | | |
| # cd $GITHUB_WORKSPACE | |
| # git add frontend/api-client/src/services/OrgService.ts frontend/api-client/package.json || true | |
| # if ! git diff --cached --quiet; then | |
| # git commit -m "chore(api-client): update OrgService and version v${{ inputs.version }}" | |
| # git push origin HEAD:${BRANCH_NAME} | |
| # else | |
| # echo "No changes to commit." | |
| # fi | |
| - name: Configure npm auth for npmjs.org | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > $HOME/.npmrc | |
| - name: Publish to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: pnpm run publish |