Skip to content

Commit 4d3b0ea

Browse files
committed
ci: add release
1 parent b1a60c9 commit 4d3b0ea

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
node-version-file: '.nvmrc'
2525
registry-url: 'https://npm.pkg.github.com'
2626

27-
- name: Lint
27+
- name: Build
2828
run: |
2929
npm ci --audit=false
3030
npm run build

.github/workflows/release.yml

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,65 @@
1-
name: Release
1+
name: Publish to GitHub Packages Registry
22

33
on:
4-
workflow_dispatch:
4+
push:
5+
branches:
6+
- testing
7+
- production
58

69
jobs:
710
release:
811
name: Release
9-
runs-on: ubuntu-latest
12+
runs-on: buildjet-2vcpu-ubuntu-2204-arm
1013
steps:
11-
- run: echo "Placeholder"
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: '.nvmrc'
21+
registry-url: 'https://npm.pkg.github.com'
22+
23+
- name: Build
24+
run: |
25+
npm ci --audit=false
26+
npm run build
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}
29+
30+
# Sets package.json name & version to environment.
31+
- name: Get Package Info
32+
run: |
33+
NAME="$(node -p "require('./package.json').name")"
34+
echo package_name=${NAME} >> $GITHUB_ENV
35+
36+
VERSION="$(node -p "require('./package.json').version")"
37+
echo package_version=${VERSION} >> $GITHUB_ENV
38+
39+
# Publish when this action is running on branch production.
40+
- name: Publish
41+
if: github.ref == 'refs/heads/production'
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
npm publish
46+
47+
# Publish to beta when this action is running on branch testing.
48+
- name: Publish (beta)
49+
if: github.ref == 'refs/heads/testing'
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
npm publish --tag beta
54+
55+
# Post a Slack notification on success/failure
56+
- name: Slack notify
57+
if: always()
58+
uses: innocarpe/actions-slack@v1
59+
with:
60+
status: ${{ job.status }}
61+
success_text: '${{github.repository}} - Published ${{ env.package_name }}@${{ env.package_version }} to GitHub Packages Registry 🚀'
62+
failure_text: '${{github.repository}} - Failed to publish ${{ env.package_name }}@${{ env.package_version }} to GitHub Packages Registry'
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)