-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (103 loc) · 3.88 KB
/
Copy pathpublish.yml
File metadata and controls
118 lines (103 loc) · 3.88 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Publish @flexmonster/angular to npm
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (used for @flexmonster/angular and the @flexmonster/js peer dependency)'
required: true
type: string
tag:
description: 'npm dist-tag to publish under'
required: true
type: choice
default: 'latest'
options:
- latest
- next
- beta
dry_run:
description: 'Dry run (do not actually publish to npm)'
required: false
type: boolean
default: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Resolve version and dist-tag
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_TAG: ${{ inputs.tag }}
run: |
VERSION="$INPUT_VERSION"
DIST_TAG="$INPUT_TAG"
echo "value=$VERSION" >> "$GITHUB_OUTPUT"
echo "dist_tag=$DIST_TAG" >> "$GITHUB_OUTPUT"
echo "tag_flag=--tag $DIST_TAG" >> "$GITHUB_OUTPUT"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
scope: '@flexmonster'
- name: Check if version already exists
env:
VERSION: ${{ steps.version.outputs.value }}
run: |
PKG_NAME=$(node -p "require('./projects/flexmonster/angular/package.json').name")
if npm view "${PKG_NAME}@${VERSION}" version --registry https://registry.npmjs.org 2>/dev/null; then
echo "::error::Version ${VERSION} already exists on npm."
exit 1
fi
- name: Set package version
working-directory: projects/flexmonster/angular
env:
VERSION: ${{ steps.version.outputs.value }}
run: npm version "$VERSION" --no-git-tag-version
- name: Bump @flexmonster/js peer dependency
working-directory: projects/flexmonster/angular
env:
JS_VERSION: ${{ steps.version.outputs.value }}
run: npm pkg set "peerDependencies.@flexmonster/js=$JS_VERSION"
- name: Install dependencies (also pins @flexmonster/js in root to the published peer)
env:
JS_VERSION: ${{ steps.version.outputs.value }}
run: npm install "@flexmonster/js@$JS_VERSION" --save-exact --no-audit --no-fund
- name: Build
run: npx ng build @flexmonster/angular
- name: Copy LICENSE and README to release folder
run: |
cp LICENSE dist/flexmonster/angular/LICENSE
cp README.md dist/flexmonster/angular/README.md
- name: Show package.json after version bump
run: cat dist/flexmonster/angular/package.json
- name: Publish package (dry run)
if: ${{ inputs.dry_run }}
working-directory: dist/flexmonster/angular
run: npm publish ${{ steps.version.outputs.tag_flag }} --dry-run
- name: Publish package
if: ${{ !inputs.dry_run }}
working-directory: dist/flexmonster/angular
run: npm publish ${{ steps.version.outputs.tag_flag }}
- name: Commit and push version bump
if: ${{ !inputs.dry_run }}
env:
VERSION: ${{ steps.version.outputs.value }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add projects/flexmonster/angular/package.json package.json package-lock.json
if git diff --cached --quiet; then
echo "No changes to commit."
exit 0
fi
git commit -m "Release v$VERSION"
git push origin "HEAD:${GITHUB_REF#refs/heads/}"