Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support preview release using pkg-pr-new #54

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Preview Release

on:
push:
branches:
- main
pull_request:
Comment on lines +3 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add permissions and consider restricting PR triggers

The workflow should:

  1. Declare required permissions explicitly
  2. Consider restricting PR triggers to trusted sources to prevent unauthorized preview releases
 name: Preview Release

 on:
   push:
     branches:
       - main
   pull_request:
+    types: [opened, synchronize]
+    branches:
+      - main
+
+permissions:
+  contents: read
+  packages: write
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
push:
branches:
- main
pull_request:
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]
branches:
- main
permissions:
contents: read
packages: write


jobs:
preview-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- run: corepack enable

- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Publish packages preview with pkg-pr-new CLI
run: pnpx pkg-pr-new publish
Comment on lines +28 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add authentication setup for package publishing

The publish step needs:

  1. Authentication setup for the package registry
  2. Error handling for failed publishes
  3. Conditional execution based on branch/PR context
       - name: Publish packages preview with pkg-pr-new CLI
+        env:
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+        if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
         run: pnpx pkg-pr-new publish
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Publish packages preview with pkg-pr-new CLI
run: pnpx pkg-pr-new publish
- name: Publish packages preview with pkg-pr-new CLI
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
run: pnpx pkg-pr-new publish

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"maplibre-gl": "5.0.0-pre.9",
"mdsvex": "^0.12.3",
"mode-watcher": "^0.5.0",
"pkg-pr-new": "^0.0.37",
"pmtiles": "^4.0.1",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.2",
Expand Down
Loading
Loading