Skip to content

Commit

Permalink
Publish packages
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Feb 21, 2024
1 parent 6770f68 commit da7b826
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
58 changes: 57 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
name: Build / Node ${{ matrix.node-version }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 18, 20, 21 ]
Expand All @@ -38,3 +38,59 @@ jobs:
steps:
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
- run: exit 0

publish-npm:
name: Publish / npm / ${{ matrix.target }}
runs-on: ubuntu-latest
needs: [success]
permissions:
contents: read
id-token: write
pull-requests: write
strategy:
matrix:
target: [ "@gw2api/types", "@gw2api/fetch" ]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 21
cache: 'npm'
- name: Build package
run: npm run build -w ${{ matrix.target }}
- name: Run Publish
run: npm run publish-package -w ${{ matrix.target }}
id: publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
GITHUB_EVENT_NAME: ${{ github.event_name }}
- name: Find Comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Publish / npm / ${{ matrix.target }}
- name: Delete comment if found but nothing will be published
if: github.event_name == 'pull_request' && steps.fc.outputs.comment-id && !steps.publish.outputs.publish
uses: actions/github-script@v7
with:
script: |
github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ steps.fc.outputs.comment-id }}
})
- name: Add comment with packages to be published
if: github.event_name == 'pull_request' && steps.publish.outputs.publish
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
**Publish / npm / ${{ matrix.target }}**
Merging this PR will publish the npm package `${{ steps.publish.outputs.publish }}`
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion packages/fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
],
"scripts": {
"test": "tsc --noEmit",
"build": "tsc"
"build": "tsc",
"publish-package": "gw2treasures-publish-package"
},
"dependencies": {
"@gw2api/types": "0.0.1"
},
"devDependencies": {
"@gw2treasures/publish-package": "0.0.1",
"typescript": "^5.2.2"
},
"publishConfig": {
"access": "public"
}
}
8 changes: 7 additions & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@
"typescript"
],
"scripts": {
"test": "tsc"
"test": "tsc",
"build": "tsc",
"publish-package": "gw2treasures-publish-package"
},
"devDependencies": {
"@gw2treasures/publish-package": "0.0.1",
"typescript": "^5.2.2"
},
"publishConfig": {
"access": "public"
}
}

0 comments on commit da7b826

Please sign in to comment.