@purpleschool/rugpt-lib-common 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,116 @@
1
+ name: Deploy Library Package
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ jobs:
8
+ check-version:
9
+ name: Check package version
10
+ runs-on: ubuntu-latest
11
+ outputs:
12
+ should_publish: ${{ steps.local.outputs.should_publish }}
13
+ version: ${{ steps.local.outputs.version }}
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v6
17
+
18
+ - name: Setup Node.js
19
+ uses: actions/setup-node@v6
20
+ with:
21
+ node-version: '20.x'
22
+
23
+ - name: Get local version
24
+ working-directory: '.'
25
+ id: local
26
+ run: |
27
+ PACKAGE_NAME=$(node -p "require('./package.json').name")
28
+ LOCAL_VERSION=$(node -p "require('./package.json').version")
29
+
30
+ echo "version=$LOCAL_VERSION" >> $GITHUB_OUTPUT
31
+ echo "Local package: $PACKAGE_NAME@$LOCAL_VERSION"
32
+
33
+ if npm view "$PACKAGE_NAME@$LOCAL_VERSION" version > /dev/null 2>&1; then
34
+ echo "Version $LOCAL_VERSION already exists on npm. Stopping job."
35
+ echo "should_publish=false" >> $GITHUB_OUTPUT
36
+ else
37
+ echo "Version $LOCAL_VERSION does not exist on npm. Publishing."
38
+ echo "should_publish=true" >> $GITHUB_OUTPUT
39
+ fi
40
+
41
+ send-already-exists-telegram:
42
+ name: Send start Telegram message
43
+ needs: [check-version]
44
+ if: needs.check-version.outputs.should_publish == 'false'
45
+ uses: ./.github/workflows/telegram-notify.yml
46
+ with:
47
+ message: |
48
+ ✅ Публикация контрактов <b>${{ github.REPOSITORY }}</b> не требуется
49
+ 📝 Текущая версия пакета: <b>${{ needs.check-version.outputs.version }}</b>
50
+ secrets: inherit
51
+
52
+ send-start-telegram:
53
+ name: Send start Telegram message
54
+ needs: [check-version]
55
+ if: needs.check-version.outputs.should_publish == 'true'
56
+ uses: ./.github/workflows/telegram-notify.yml
57
+ with:
58
+ message: |
59
+ 🏹 Публикация контрактов <b>${{ github.REPOSITORY }}</b> началась
60
+
61
+ 📝 Commit message: <b>${{ github.event.head_commit.message }}</b>
62
+ ✍🏻 Author: <b>${{ github.event.head_commit.author.name }}</b>
63
+ 🕐 Commit timestamp: <b>${{ github.event.head_commit.timestamp }}</b>
64
+
65
+ 🔗 <b>Links:</b>
66
+ <a href='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'>View CI/CD Run</a>
67
+ secrets: inherit
68
+
69
+ publish:
70
+ name: Publish package
71
+ needs: [check-version]
72
+ if: needs.check-version.outputs.should_publish == 'true'
73
+ runs-on: ubuntu-latest
74
+ steps:
75
+ - name: Checkout
76
+ uses: actions/checkout@v6
77
+
78
+ - name: Setup Node
79
+ uses: actions/setup-node@v6
80
+ with:
81
+ node-version: '20.x'
82
+ registry-url: 'https://registry.npmjs.org'
83
+
84
+ - name: Install dependencies and build
85
+ working-directory: '.'
86
+ run: npm ci && npm run prepublish
87
+
88
+ - name: Publish package on NPM
89
+ working-directory: '.'
90
+ run: npm publish --access public
91
+ env:
92
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
93
+
94
+ notify-success:
95
+ needs: [publish, check-version]
96
+ if: success()
97
+ uses: ./.github/workflows/telegram-notify.yml
98
+ with:
99
+ message: |
100
+ ✅ <b>${{ github.repository }}</b> контракты успешно опубликованы 😎
101
+ 📝 Опубликованная версия: <b>${{ needs.check-version.outputs.version }}</b>
102
+ secrets: inherit
103
+
104
+ notify-failure:
105
+ needs: [publish]
106
+ if: failure()
107
+ uses: ./.github/workflows/telegram-notify.yml
108
+ with:
109
+ message: |
110
+ ❌ Публикация контрактов <b>${{ github.repository }}</b> упала с ошибкой 😡
111
+ 📝 Version: <b>${{ needs.check-version.outputs.version }}</b>
112
+ ✍🏻 Author: <b>${{ github.event.head_commit.author.name }}</b>
113
+
114
+ 🔗 <b>Links:</b>
115
+ <a href='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'>View CI/CD Run</a>
116
+ secrets: inherit
@@ -0,0 +1,30 @@
1
+ name: Telegram Notification Template
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ message:
7
+ required: true
8
+ type: string
9
+ status:
10
+ required: false
11
+ type: string
12
+ default: 'info'
13
+ secrets:
14
+ TELEGRAM_CHAT_ID:
15
+ required: true
16
+ TELEGRAM_TOKEN:
17
+ required: true
18
+
19
+ jobs:
20
+ notify:
21
+ runs-on: self-hosted
22
+ steps:
23
+ - name: Send Telegram notification
24
+ uses: appleboy/telegram-action@master
25
+ with:
26
+ to: ${{ secrets.TELEGRAM_CHAT_ID }}
27
+ token: ${{ secrets.TELEGRAM_TOKEN }}
28
+ format: html
29
+ message: |
30
+ ${{ inputs.message }}