Skip to content

Commit de51eab

Browse files
committed
publish workflow
1 parent 7cf1353 commit de51eab

File tree

2 files changed

+73
-58
lines changed

2 files changed

+73
-58
lines changed

.github/workflows/publish.yml

Lines changed: 72 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,89 @@
1-
name: Publish
1+
name: 📨 Publish
22

33
on:
44
release:
5-
types: [published, prereleased]
5+
types: published
66

77
permissions:
8+
id-token: write
89
contents: read
910

1011
jobs:
12+
code_check:
13+
name: 🔬 PR Checks
14+
uses: ./.github/workflows/check.yml
15+
secrets:
16+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
17+
1118
publish:
19+
name: 📮 to npm
1220
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+
1327
concurrency:
1428
group: publish-${{ github.event.release.tag_name }}
1529
cancel-in-progress: true
16-
environment:
17-
name: npm
18-
url: ${{ github.event.release.html_url }}
30+
1931
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
2734

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"
3742
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"
5059
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 }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "@digital-alchemy/automation",
44
"repository": "https://github.com/Digital-Alchemy-TS/automation",
55
"homepage": "https://docs.digital-alchemy.app/Automation",
6-
"version": "25.8.21",
6+
"version": "25.11.18",
77
"scripts": {
88
"build": "rm -rf dist/; tsc",
99
"lint": "eslint src",

0 commit comments

Comments
 (0)