Publish package #38
Workflow file for this run
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: Publish package | |
| on: | |
| push: | |
| tags: | |
| - v*.*.* | |
| jobs: | |
| publish-to-npm: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| registry-url: 'https://registry.npmjs.org' | |
| scope: ${{ github.repository_owner }} | |
| - name: Update package.json | |
| run: | | |
| TAG_NAME=${GITHUB_REF/refs\/tags\//} | |
| PACKAGE_VERSION=${TAG_NAME#v} | |
| echo "Updating package.json to version $PACKAGE_VERSION" | |
| cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json | |
| cat package.json | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build | |
| run: yarn build | |
| # Workaround for old version of package managers (like yarn v1) that do not support OIDC natively | |
| - name: Exchange OIDC token for short-lived npm token | |
| id: exchange | |
| run: | | |
| PKG_NAME=$(jq -r .name package.json) | |
| curl -v -sSL -H "Authorization: Bearer $ID_TOKEN" "https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/${PKG_NAME} | |
| # NPM_TOKEN=$(curl -sSL -H "Authorization: Bearer $ID_TOKEN" \ | |
| # "https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/${PKG_NAME}" \ | |
| # | jq -r '.token') | |
| # echo "NPM_TOKEN=$NPM_TOKEN" >> $GITHUB_ENV | |
| # - name: Publish | |
| # run: yarn publish | |
| # working-directory: dist | |
| # env: | |
| # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| publish-to-github: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: ${{ github.repository_owner }} | |
| - name: Update package.json | |
| run: | | |
| TAG_NAME=${GITHUB_REF/refs\/tags\//} | |
| PACKAGE_VERSION=${TAG_NAME#v} | |
| echo "Updating package.json to version $PACKAGE_VERSION" | |
| cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json | |
| cat package.json | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build | |
| run: yarn build | |
| # - name: Publish | |
| # run: yarn publish | |
| # working-directory: dist | |
| # env: | |
| # NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |