@anddone/coretestautomation 1.0.7 → 1.0.8

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.
@@ -1,4 +1,4 @@
1
- name: Release CoreTestAutomation
1
+ name: Old Workflow Release CoreTestAutomation
2
2
 
3
3
  on:
4
4
  workflow_dispatch:
@@ -0,0 +1,145 @@
1
+ name: Publish-CoreTestAutomation
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+ issues: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0
18
+
19
+ - uses: actions/setup-node@v4
20
+ with:
21
+ node-version: 18
22
+ registry-url: https://registry.npmjs.org/
23
+
24
+ - name: Install dependencies
25
+ run: npm install
26
+
27
+ - name: Create approval issue
28
+ id: approval_issue
29
+ uses: actions/github-script@v7
30
+ with:
31
+ script: |
32
+ const body = [
33
+ "Approval required for npm publish",
34
+ "",
35
+ "Package: @anddone/coretestautomation",
36
+ `Run ID: ${context.runId}`,
37
+ "",
38
+ "Approvers:",
39
+ "@ad-amolpatil",
40
+ "@ad-rushabhGunjal",
41
+ "@ad-siddheshwaranajekar",
42
+ "@ad-dbharathidasan",
43
+ "",
44
+ "Please comment APPROVE to proceed."
45
+ ].join("\n");
46
+
47
+ const { data: issue } = await github.rest.issues.create({
48
+ owner: context.repo.owner,
49
+ repo: context.repo.repo,
50
+ title: "Approval required: Publish coretestautomation",
51
+ body
52
+ });
53
+
54
+ core.setOutput("issue_number", issue.number);
55
+
56
+ - name: Wait for approval
57
+ uses: actions/github-script@v7
58
+ with:
59
+ script: |
60
+ const owner = context.repo.owner;
61
+ const repo = context.repo.repo;
62
+ const issue_number = Number('${{ steps.approval_issue.outputs.issue_number }}');
63
+
64
+ const APPROVERS = [
65
+ 'ad-amolpatil',
66
+ 'ad-rushabhGunjal',
67
+ 'ad-siddheshwaranajekar',
68
+ 'ad-dbharathidasan'
69
+ ];
70
+
71
+ const TIMEOUT_MINUTES = 60;
72
+ const POLL_MS = 30000;
73
+ const start = Date.now();
74
+
75
+ while (true) {
76
+ const { data: comments } = await github.rest.issues.listComments({
77
+ owner,
78
+ repo,
79
+ issue_number,
80
+ per_page: 100
81
+ });
82
+
83
+ const approved = comments.some(c =>
84
+ APPROVERS.includes(c.user.login) &&
85
+ c.body.trim().toUpperCase() === 'APPROVE'
86
+ );
87
+
88
+ if (approved) break;
89
+
90
+ if ((Date.now() - start) / 60000 > TIMEOUT_MINUTES) {
91
+ core.setFailed('Timed out waiting for approval.');
92
+ break;
93
+ }
94
+
95
+ await new Promise(res => setTimeout(res, POLL_MS));
96
+ }
97
+
98
+ - name: Configure npm auth
99
+ run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
100
+ env:
101
+ NODE_AUTH_TOKEN: ${{ secrets.TESTAUTOMATIONAUTH }}
102
+
103
+ - name: Publish to npm
104
+ run: npm publish --access public
105
+ env:
106
+ NODE_AUTH_TOKEN: ${{ secrets.TESTAUTOMATIONAUTH }}
107
+
108
+ - name: Read release notes from tag
109
+ if: success()
110
+ run: |
111
+ VERSION=$(node -p "require('./package.json').version")
112
+ # Read annotated tag body and write to file — safest way to handle multiline/special chars
113
+ git for-each-ref --format='%(contents:body)' "refs/tags/v${VERSION}" 2>/dev/null > /tmp/release_notes.txt
114
+
115
+ if [ ! -s /tmp/release_notes.txt ]; then
116
+ echo "(No release notes available)" > /tmp/release_notes.txt
117
+ fi
118
+
119
+ - name: Slack success (dev channel)
120
+ if: success()
121
+ continue-on-error: true
122
+ env:
123
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
124
+ run: |
125
+ PACKAGE_NAME="@anddone/coretestautomation"
126
+ VERSION=$(node -p "require('./package.json').version")
127
+ NOTES=$(cat /tmp/release_notes.txt)
128
+
129
+ PAYLOAD=$(jq -n \
130
+ --arg pkg "$PACKAGE_NAME" \
131
+ --arg ver "$VERSION" \
132
+ --arg notes "$NOTES" \
133
+ '{text: ("NPM package published\n\nPackage: " + $pkg + "\nVersion: " + $ver + "\n\nRelease Notes:\n" + $notes)}')
134
+
135
+ HTTP_STATUS=$(curl -s -o /tmp/slack_response.txt -w "%{http_code}" \
136
+ -X POST \
137
+ -H "Content-type: application/json" \
138
+ --data "$PAYLOAD" \
139
+ "$SLACK_WEBHOOK_URL")
140
+
141
+ echo "Slack response: HTTP $HTTP_STATUS — $(cat /tmp/slack_response.txt)"
142
+
143
+ if [ "$HTTP_STATUS" != "200" ]; then
144
+ echo "::warning::Slack notification failed with HTTP $HTTP_STATUS"
145
+ fi
@@ -0,0 +1,104 @@
1
+ name: Release CoreTestAutomation
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ release_type:
7
+ description: "Release type (semantic versioning)"
8
+ required: true
9
+ default: patch
10
+ type: choice
11
+ options:
12
+ - patch
13
+ - minor
14
+ - major
15
+ release_notes:
16
+ description: "Release notes"
17
+ required: false
18
+
19
+ permissions:
20
+ contents: write
21
+
22
+ jobs:
23
+ release:
24
+ runs-on: ubuntu-latest
25
+
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ with:
29
+ fetch-depth: 0
30
+
31
+ - uses: actions/setup-node@v4
32
+ with:
33
+ node-version: 18
34
+
35
+ - name: Install dependencies
36
+ run: npm install
37
+
38
+ - name: Build project
39
+ run: npm run build
40
+
41
+ - name: Configure Git
42
+ run: |
43
+ git config user.name "github-actions[bot]"
44
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
45
+
46
+ - name: Write release notes to file
47
+ env:
48
+ RELEASE_NOTES: ${{ github.event.inputs.release_notes }}
49
+ run: |
50
+ if [ -z "$RELEASE_NOTES" ]; then
51
+ echo "No release notes provided" > /tmp/release_notes.txt
52
+ else
53
+ echo "$RELEASE_NOTES" > /tmp/release_notes.txt
54
+ fi
55
+
56
+ - name: Bump version and create annotated tag
57
+ run: |
58
+ RELEASE_TYPE="${{ inputs.release_type }}"
59
+
60
+ NEW_VERSION=$(npm version "$RELEASE_TYPE" --no-git-tag-version | sed 's/^v//')
61
+
62
+ git add package.json
63
+ git commit -m "chore(release): v$NEW_VERSION"
64
+
65
+ {
66
+ echo "Release v$NEW_VERSION"
67
+ echo ""
68
+ cat /tmp/release_notes.txt
69
+ } > /tmp/tag_message.txt
70
+
71
+ git tag -a "v${NEW_VERSION}" -F /tmp/tag_message.txt
72
+ git push origin HEAD --follow-tags
73
+
74
+ - name: Notify approvers on Slack
75
+ if: success()
76
+ continue-on-error: true
77
+ env:
78
+ SLACK_URL: ${{ secrets.SLACK_URL }}
79
+ run: |
80
+ PACKAGE_NAME="@anddone/coretestautomation"
81
+ VERSION=$(node -p "require('./package.json').version")
82
+ NOTES=$(cat /tmp/release_notes.txt)
83
+ TAGS="<@U03U65PTMC3> <@U06KZU9FT4M> <@U06KN9E3ZFZ>"
84
+ PUBLISH_URL="https://github.com/${{ github.repository }}/actions/workflows/publish-coretest.yml"
85
+
86
+ PAYLOAD=$(jq -n \
87
+ --arg tags "$TAGS" \
88
+ --arg pkg "$PACKAGE_NAME" \
89
+ --arg ver "$VERSION" \
90
+ --arg notes "$NOTES" \
91
+ --arg url "$PUBLISH_URL" \
92
+ '{text: ($tags + " Release ready for approval\n\nPackage: " + $pkg + "\nVersion: " + $ver + "\n\nRelease Notes:\n" + $notes + "\n\nTrigger publish here:\n" + $url)}')
93
+
94
+ HTTP_STATUS=$(curl -s -o /tmp/slack_response.txt -w "%{http_code}" \
95
+ -X POST \
96
+ -H "Content-type: application/json" \
97
+ --data "$PAYLOAD" \
98
+ "$SLACK_URL")
99
+
100
+ echo "Slack response: HTTP $HTTP_STATUS — $(cat /tmp/slack_response.txt)"
101
+
102
+ if [ "$HTTP_STATUS" != "200" ]; then
103
+ echo "::warning::Slack notification failed with HTTP $HTTP_STATUS"
104
+ fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anddone/coretestautomation",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "main": "index.js",
5
5
  "type": "commonjs",
6
6
  "scripts": {