|
1 | | -name: Publish |
| 1 | +name: 📨 Publish |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | release: |
5 | | - types: [published, prereleased] |
| 5 | + types: published |
6 | 6 |
|
7 | 7 | permissions: |
| 8 | + id-token: write |
8 | 9 | contents: read |
9 | 10 |
|
10 | 11 | jobs: |
| 12 | + code_check: |
| 13 | + name: 🔬 PR Checks |
| 14 | + uses: ./.github/workflows/check.yml |
| 15 | + secrets: |
| 16 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 17 | + |
11 | 18 | publish: |
| 19 | + name: 📮 to npm |
12 | 20 | runs-on: ubuntu-latest |
| 21 | + needs: code_check |
| 22 | + |
| 23 | + environment: |
| 24 | + name: ${{ github.event.release.prerelease && 'npm-prerelease' || 'npm' }} |
| 25 | + url: ${{ github.event.release.html_url }} |
| 26 | + |
13 | 27 | concurrency: |
14 | 28 | group: publish-${{ github.event.release.tag_name }} |
15 | 29 | cancel-in-progress: true |
16 | | - environment: |
17 | | - name: npm |
18 | | - url: ${{ github.event.release.html_url }} |
| 30 | + |
19 | 31 | steps: |
20 | | - - uses: actions/checkout@v5 |
21 | | - - uses: actions/setup-node@v4 |
22 | | - with: |
23 | | - node-version: '22' |
24 | | - registry-url: 'https://registry.npmjs.org/' |
25 | | - - run: corepack enable |
26 | | - - run: yarn config set enableImmutableInstalls false |
| 32 | + - name: 🧾 Checkout |
| 33 | + uses: actions/checkout@v5 |
27 | 34 |
|
28 | | - - run: yarn |
29 | | - - run: yarn build |
30 | | - - run: yarn lint |
31 | | - - name: Check package version |
32 | | - env: |
33 | | - IS_PRERELEASE: ${{ github.event.release.prerelease }} |
34 | | - run: | |
35 | | - PACKAGE_VERSION=$(node -p "require('./package.json').version") |
36 | | - echo "Package version: $PACKAGE_VERSION" |
| 35 | + - name: 🔎 Get package version |
| 36 | + id: package_version |
| 37 | + env: |
| 38 | + IS_PRERELEASE: ${{ github.event.release.prerelease }} |
| 39 | + run: | |
| 40 | + PACKAGE_VERSION=$(jq -r '.version' package.json) |
| 41 | + echo "Package version: $PACKAGE_VERSION" |
37 | 42 |
|
38 | | - if [[ "$IS_PRERELEASE" == "true" ]]; then |
39 | | - # For prereleases, version must contain -beta |
40 | | - if [[ "$PACKAGE_VERSION" != *"-beta"* ]]; then |
41 | | - echo "❌ Prerelease failed: Package version '$PACKAGE_VERSION' must contain '-beta'" |
42 | | - exit 1 |
43 | | - fi |
44 | | - echo "✅ Prerelease version check passed" |
45 | | - else |
46 | | - # For releases, version must NOT contain -beta |
47 | | - if [[ "$PACKAGE_VERSION" == *"-beta"* ]]; then |
48 | | - echo "❌ Release failed: Package version '$PACKAGE_VERSION' cannot contain '-beta'" |
49 | | - exit 1 |
| 43 | + if [[ "$IS_PRERELEASE" == "true" ]]; then |
| 44 | + # For prereleases, version must contain -beta |
| 45 | + if [[ "$PACKAGE_VERSION" != *"-beta"* ]]; then |
| 46 | + echo "❌ Prerelease failed: Package version '$PACKAGE_VERSION' must contain '-beta'" |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + echo "version=beta" >> $GITHUB_OUTPUT |
| 50 | + echo "✅ Prerelease version check passed" |
| 51 | + else |
| 52 | + # For releases, version must NOT contain -beta |
| 53 | + if [[ "$PACKAGE_VERSION" == *"-beta"* ]]; then |
| 54 | + echo "❌ Release failed: Package version '$PACKAGE_VERSION' cannot contain '-beta'" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + echo "version=latest" >> $GITHUB_OUTPUT |
| 58 | + echo "✅ Release version check passed" |
50 | 59 | fi |
51 | | - echo "✅ Release version check passed" |
52 | | - fi |
53 | | - - name: Publish to npm |
54 | | - env: |
55 | | - IS_PRERELEASE: ${{ github.event.release.prerelease }} |
56 | | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
57 | | - run: | |
58 | | - npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN |
59 | | - if [[ "$IS_PRERELEASE" == "true" ]]; then |
60 | | - npm publish --tag beta |
61 | | - else |
62 | | - npm publish |
63 | | - fi |
64 | | - - name: Send Discord Notification |
65 | | - if: ${{ !github.event.release.prerelease }} |
66 | | - uses: sarisia/actions-status-discord@v1 |
67 | | - with: |
68 | | - webhook: ${{ secrets.DISCORD_WEBHOOK }} |
69 | | - nodetail: true |
70 | | - url: ${{ github.event.release.html_url }} |
71 | | - title: 🚀 **RELEASE** **@digital-alchemy/automation ${{ github.event.release.tag_name }}** published |
72 | | - content: | |
73 | | - (${{ github.event.release.tag_name }}) **${{ github.event.release.name }}** |
74 | | - ${{ github.event.release.body }} |
| 60 | +
|
| 61 | + - uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version: '22' |
| 64 | + registry-url: 'https://registry.npmjs.org/' |
| 65 | + |
| 66 | + - name: 📦 Create build |
| 67 | + run: | |
| 68 | + npm install -g npm |
| 69 | + corepack enable |
| 70 | + yarn config set enableImmutableInstalls false |
| 71 | + yarn |
| 72 | + yarn build |
| 73 | +
|
| 74 | + - name: 📨 Publish to npm |
| 75 | + env: |
| 76 | + RELEASE_TAG: ${{ steps.package_version.outputs.version }} |
| 77 | + run: npm publish --tag $RELEASE_TAG |
| 78 | + |
| 79 | + - name: 📣 Send Discord Notification |
| 80 | + if: ${{ !github.event.release.prerelease }} |
| 81 | + uses: sarisia/actions-status-discord@v1 |
| 82 | + with: |
| 83 | + webhook: ${{ secrets.DISCORD_WEBHOOK }} |
| 84 | + nodetail: true |
| 85 | + url: ${{ github.event.release.html_url }} |
| 86 | + title: 🚀 **RELEASE** **@digital-alchemy/automation ${{ github.event.release.tag_name }}** published |
| 87 | + content: | |
| 88 | + (${{ github.event.release.tag_name }}) **${{ github.event.release.name }}** |
| 89 | + ${{ github.event.release.body }} |
0 commit comments