-
Notifications
You must be signed in to change notification settings - Fork 6.5k
76 lines (64 loc) · 2.61 KB
/
publish-ui-components.yml
File metadata and controls
76 lines (64 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Publish UI Components Package
on:
workflow_run:
workflows: ['Linting and Tests']
types: [completed]
branches: [main]
workflow_dispatch:
inputs:
skip_github_check:
description: 'Skip GitHub commit author check'
required: false
default: false
type: boolean
permissions:
contents: read
packages: write
env:
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
jobs:
publish:
if: github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Verify commit authenticity
run: |
COMMIT_DATA=$(gh api repos/${{ github.repository }}/commits/$COMMIT_SHA)
VERIFIED=$(echo "$COMMIT_DATA" | jq -r '.commit.verification.verified')
COMMITTER=$(echo "$COMMIT_DATA" | jq -r '.commit.committer.email')
if [[ "$VERIFIED" != "true" ]]; then
echo "❌ Unverified commit! Aborting."
exit 1
fi
if [[ "${{ github.event.inputs.skip_github_check }}" != "true" && "$COMMITTER" != "[email protected]" ]]; then
echo "❌ Unauthorized committer! Aborting."
exit 1
fi
echo "✅ Commit is verified and trusted."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for UI component changes
if: github.event_name != 'workflow_dispatch'
id: check_changes
run: |
if git diff --quiet $COMMIT_SHA~1 $COMMIT_SHA -- packages/ui-components/; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: github.event_name == 'workflow_dispatch' || steps.check_changes.outputs.changed == 'true'
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
cache: npm
registry-url: https://npm.pkg.github.com/
- name: Generate version
if: github.event_name == 'workflow_dispatch' || steps.check_changes.outputs.changed == 'true'
run: npm version --no-git-tag-version 0.0.0-$COMMIT_SHA --workspace=packages/ui-components
- name: Publish package
if: github.event_name == 'workflow_dispatch' || steps.check_changes.outputs.changed == 'true'
run: npm publish --workspace=packages/ui-components
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}