diff --git a/.github/workflows/release-apiv2-client.yml b/.github/workflows/release-apiv2-client.yml index a8c4b05d6..34ea09447 100644 --- a/.github/workflows/release-apiv2-client.yml +++ b/.github/workflows/release-apiv2-client.yml @@ -9,6 +9,9 @@ on: - "**/api_v2/**/*.py" - "apiclient/typescript-fetch/package.json" - ".github/workflows/release-apiv2-client.yml" + pull_request: + paths: + - ".github/workflows/release-apiv2-client.yml" jobs: release: @@ -47,25 +50,6 @@ jobs: env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: generate client - run: npm run generate:client - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - working-directory: ./apiclient/typescript-fetch - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: "github-actions[bot]" - body-includes: "" - - name: Create or update comment - uses: peter-evans/create-or-update-comment@v3 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - edit-mode: replace - body: | - - :zap: :zap: :zap: Now the latest apiv2 client npm package is available at: - https://github.com/dmm-com/airone/pkgs/npm/airone-apiclient-typescript-fetch/versions + run: | + source virtualenv/bin/activate + poetry run npm run generate:client diff --git a/.github/workflows/release-apiv2-client_copy.yml b/.github/workflows/release-apiv2-client_copy.yml new file mode 100644 index 000000000..dee69b3d3 --- /dev/null +++ b/.github/workflows/release-apiv2-client_copy.yml @@ -0,0 +1,50 @@ +name: Release AirOne APIv2 client npm package to GitHub npm Registry + +on: + push: + paths: + - ".github/workflows/release-apiv2-client_copy.yml" + pull_request: + paths: + - ".github/workflows/release-apiv2-client_copy.yml" + +jobs: + release_copy: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + pull-requests: write + if: ${{ github.event.label.name == 'release-apiv2-client' }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: apt-get + run: | + sudo apt-get update + sudo apt-get install libldap2-dev libsasl2-dev libxmlsec1-dev libmysqlclient-dev pkg-config + - uses: actions/setup-python@v4 + with: + python-version: "3.11.5" + - name: venv + run: | + python3 -m venv virtualenv + source virtualenv/bin/activate + pip install pip --upgrade + pip install poetry + poetry install --no-ansi + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://npm.pkg.github.com/ + scope: "@dmm-com" + - name: install dependencies + run: npm ci + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: generate client + run: | + source virtualenv/bin/activate + poetry run npm run generate:client diff --git a/tools/generate_client.sh b/tools/generate_client.sh index d850b9339..f7506fcc2 100755 --- a/tools/generate_client.sh +++ b/tools/generate_client.sh @@ -4,6 +4,7 @@ set -u OPENAPI_GENERATOR_VERSION=v6.6.0 + # detect errors on spectacular generr=$(poetry run python manage.py spectacular 2>&1 > /dev/null | grep ERROR); if [ "$generr" != "" ]; then