-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (89 loc) · 3.46 KB
/
publish.yaml
File metadata and controls
99 lines (89 loc) · 3.46 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
name: Publish Package to npmjs
on:
release:
types: [created]
env:
retention_days: 3
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full git history for version calculation
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.3.3
with:
versionSpec: "6.3.x"
- name: Determine Version
id: version_step # step id used as a reference for output values
uses: gittools/actions/gitversion/execute@v4.3.3
env:
DOTNET_GITVERSION_TELEMETRY_OPTOUT: 1
with:
configFilePath: ./GitVersion.yml
- name: Extract version information
id: extract-version
run: |
# Read GitVersion output and replace PullRequest with Patch
VERSION="${{ steps.version_step.outputs.SemVer }}"
# make 0.1.0-PullRequest99.190 to 0.1.0-Patch99.190
VERSION=$(echo "$VERSION" | sed 's/PullRequest/Patch/g')
FULL_SEMVER="${{ steps.version_step.outputs.FullSemVer }}"
MAJOR_MINOR_PATCH="${{ steps.version_step.outputs.MajorMinorPatch }}"
GIT_HASH="${{ steps.version_step.outputs.Sha }}"
GIT_TAG="${{ steps.version_step.outputs.PreReleaseTag }}"
GIT_BRANCH="${{ steps.version_step.outputs.BranchName }}"
COMMIT_COUNT="${{ steps.version_step.outputs.CommitsSinceVersionSource }}"
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Create version.txt content
cat > version-$VERSION.txt << EOF
version=$VERSION
major_minor_patch=$MAJOR_MINOR_PATCH
full_semver=$FULL_SEMVER
git_hash=$GIT_HASH
git_tag=$GIT_TAG
git_branch=$GIT_BRANCH
commit_count=$COMMIT_COUNT
build_date=$BUILD_DATE
EOF
# Output version for other steps
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "MAJOR_MINOR_PATCH=$MAJOR_MINOR_PATCH" >> $GITHUB_OUTPUT
echo "FULL_SEMVER=$FULL_SEMVER" >> $GITHUB_OUTPUT
echo "GIT_HASH=$GIT_HASH" >> $GITHUB_OUTPUT
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_OUTPUT
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_OUTPUT
echo "COMMIT_COUNT=$COMMIT_COUNT" >> $GITHUB_OUTPUT
# Display version info
echo "Generated version: $VERSION"
echo "Major minor patch: $MAJOR_MINOR_PATCH"
echo "Full semver: $FULL_SEMVER"
echo "Git hash: $GIT_HASH"
echo "Git branch: $GIT_BRANCH"
echo "Commit count: $COMMIT_COUNT"
echo "Build date: $BUILD_DATE"
echo "version.txt content:"
cat version-$VERSION.txt
- name: Update project files with version
run: |
chmod +x scripts/updateVersion.sh
bash scripts/updateVersion.sh
- name: Upload version.txt as artifact
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: version-info
path: version-${{ steps.extract-version.outputs.VERSION }}.txt
retention-days: ${{ env.retention_days }}
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v6
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm run build:client
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}