diff --git a/.github/workflows/pr-clean-package.yaml b/.github/workflows/pr-clean-package.yaml new file mode 100644 index 00000000..83dbef1c --- /dev/null +++ b/.github/workflows/pr-clean-package.yaml @@ -0,0 +1,25 @@ +name: Delete PR package + +on: + pull_request: + types: + - closed + +jobs: + delete: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - id: version + run: | + curl -X GET -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/weka/packages/npm/weka-ui-components/versions >> $HOME/versionIds.json + echo "id=$(jq -r '.[] | select(.name == "${{ github.head_ref }}").id' $HOME/versionIds.json)" >> $GITHUB_OUTPUT + + - run: echo "${{ steps.version.outputs.id }}" + + - uses: actions/delete-package-versions@v5 + with: + package-version-ids: ${{ steps.version.outputs.id }} + package-name: weka-ui-components + package-type: npm diff --git a/.github/workflows/pr-package.yaml b/.github/workflows/pr-package.yaml new file mode 100644 index 00000000..cee69f2e --- /dev/null +++ b/.github/workflows/pr-package.yaml @@ -0,0 +1,44 @@ +name: Publish PR package + +on: + pull_request: + +jobs: + publish: + if: "!contains(github.event.pull_request.labels.*.name, 'nopublish')" + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - run: echo '${{ secrets.PAT }}' | wc +# - uses: actions/checkout@v4 +# +# - uses: actions/setup-node@v4 +# with: +# node-version: '20' +# cache: 'yarn' +# registry-url: https://npm.pkg.github.com/ +# scope: '@weka' +# +# - run: echo "$(jq '.version="${{ github.head_ref }}"' package.json)" > package.json +# +# - run: yarn install +# +# - id: version +# run: | +# curl -X GET -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/weka/packages/npm/weka-ui-components/versions >> $HOME/versionIds.json +# echo "id=$(jq -r '.[] | select(.name == "${{ github.head_ref }}").id' $HOME/versionIds.json)" >> $GITHUB_OUTPUT +# +# - run: echo "${{ steps.version.outputs.id }}" +# +# - uses: actions/delete-package-versions@v5 +# with: +# package-version-ids: ${{ steps.version.outputs.id }} +# package-name: weka-ui-components +# package-type: npm +# if: ${{ steps.version.outputs.id }} +# +# - run: yarn publish +# env: +# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..649bfb3d --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,37 @@ +name: Publish package + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + registry-url: https://npm.pkg.github.com/ + scope: '@weka' + + - run: yarn install + + - run: echo "lines=$(git diff package.json | grep '+\s*"version"' -c)" >> $GITHUB_OUTPUT + id: version-diff + + - run: yarn publish --minor + if: ${{ steps.version-diff.outputs.lines == 1 }} + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: yarn publish + if: ${{ steps.version-diff.outputs.lines == 0 }} + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmrc b/.npmrc index bfffa4ed..c5cd7b2e 100644 --- a/.npmrc +++ b/.npmrc @@ -2,3 +2,6 @@ //npm.fontawesome.com/C1F19C49-B88B-4523-8273-6C86A14E7F58=TOKEN //npm.fontawesome.com/:_authToken=C1F19C49-B88B-4523-8273-6C86A14E7F58 //registry.npmjs.org/:_authToken=52d68335-e507-46a1-835f-c73f19279b12 +@weka:registry=https://npm.pkg.github.com +registry=https://registry.yarnpkg.com/ +always-auth=true diff --git a/package.json b/package.json index ec8e3d29..5069a5a9 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,12 @@ { - "name": "@weka.io/weka-ui-components", + "name": "@weka/weka-ui-components", + "repository": { + "type": "git", + "url": "https://github.com/weka/weka-ui-components.git" + }, + "publishConfig": { + "registry": "https://npm.pkg.github.com" + }, "version": "1.77.0", "main": "dist/cjs/index.js", "module": "dist/esm/index.js",