|
1 | | -name: Publish |
| 1 | +name: Publish to npm |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - 'v*' |
| 4 | + release: |
| 5 | + types: [published] # Berjalan otomatis saat Anda membuat Release baru di GitHub |
| 6 | + # Atau jika ingin dijalankan manual lewat tab Actions: |
| 7 | + workflow_dispatch: |
7 | 8 |
|
8 | 9 | jobs: |
9 | | - test: |
10 | | - runs-on: ${{ matrix.os }} |
11 | | - strategy: |
12 | | - matrix: |
13 | | - os: [ubuntu-latest, windows-latest, macos-latest] |
14 | | - python-version: ["3.11", "3.12"] |
15 | | - steps: |
16 | | - - uses: actions/checkout@v4 |
17 | | - |
18 | | - - name: Set up Python ${{ matrix.python-version }} |
19 | | - uses: actions/setup-python@v5 |
20 | | - with: |
21 | | - python-version: ${{ matrix.python-version }} |
22 | | - |
23 | | - - name: Install dependencies |
24 | | - run: | |
25 | | - python -m pip install --upgrade pip |
26 | | - python -m pip install -e ".[dev]" |
27 | | -
|
28 | | - - name: Compile check |
29 | | - run: python -m compileall fincli -q |
30 | | - |
31 | | - - name: Run tests |
32 | | - run: pytest -q |
33 | | - |
34 | | - - name: Prepublish scan |
35 | | - run: python scripts/prepublish_check.py --skip-pack |
36 | | - |
37 | | - publish-npm: |
38 | | - needs: test |
| 10 | + publish: |
39 | 11 | runs-on: ubuntu-latest |
| 12 | + # PENTING: Permission ini wajib ada untuk menggunakan OIDC Trusted Publisher |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + id-token: write |
| 16 | + |
40 | 17 | steps: |
41 | | - - uses: actions/checkout@v4 |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
42 | 20 |
|
43 | | - - name: Set up Node.js |
| 21 | + - name: Setup Node.js |
44 | 22 | uses: actions/setup-node@v4 |
45 | 23 | with: |
46 | | - node-version: "20" |
47 | | - registry-url: "https://registry.npmjs.org" |
| 24 | + node-version: '20' |
| 25 | + registry-url: 'https://registry.npmjs.org' |
48 | 26 |
|
49 | | - - name: npm pack dry-run |
50 | | - run: npm pack --dry-run |
| 27 | + - name: Install dependencies |
| 28 | + run: npm ci |
51 | 29 |
|
| 30 | + # Langkah publish menggunakan OIDC (tanpa token) |
52 | 31 | - name: Publish to npm |
53 | | - run: npm publish --access=public |
54 | | - env: |
55 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
56 | | - |
57 | | - publish-pypi: |
58 | | - needs: test |
59 | | - runs-on: ubuntu-latest |
60 | | - steps: |
61 | | - - uses: actions/checkout@v4 |
62 | | - |
63 | | - - name: Set up Python |
64 | | - uses: actions/setup-python@v5 |
65 | | - with: |
66 | | - python-version: "3.12" |
67 | | - |
68 | | - - name: Install build tools |
69 | | - run: python -m pip install --upgrade pip build twine |
70 | | - |
71 | | - - name: Build package |
72 | | - run: python -m build |
73 | | - |
74 | | - - name: Publish to PyPI |
75 | | - run: python -m twine upload dist/* |
76 | | - env: |
77 | | - TWINE_USERNAME: __token__ |
78 | | - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 32 | + run: npm publish --provenance |
0 commit comments