Repository navigation
134 lines (110 loc) · 3.5 KB
/
Copy pathpublish.yml
File metadata and controls
134 lines (110 loc) · 3.5 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Publish Package
on:
push:
tags:
- 'v*'
branches:
- develop
permissions:
id-token: write # Required for OIDC
contents: write # Required for GitHub releases
jobs:
publish-release:
name: Release (tag)
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.0
- name: Use Node.js 24
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm run build
- name: Run tests
run: pnpm run test
- name: Publish to npm
run: npm publish --access public
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "GitHub release ${TAG} already exists, skipping"
exit 0
fi
NOTES="$(awk -v ver="$VERSION" '
$0 == "## " ver {p=1; next}
p && /^## / {exit}
p
' CHANGELOG.md)"
gh release create "$TAG" \
--title "$TAG" \
--notes "$NOTES" \
--generate-notes \
--latest
publish-prerelease:
name: Pre-release (develop)
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.0
- name: Use Node.js 24
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Generate pre-release version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
SHORT_SHA=$(git rev-parse --short HEAD)
TIMESTAMP=$(date +%Y%m%d%H%M%S)
PRE_RELEASE_VERSION="${CURRENT_VERSION}-beta.${TIMESTAMP}.${SHORT_SHA}"
echo "Pre-release version: $PRE_RELEASE_VERSION"
echo "PRE_RELEASE_VERSION=$PRE_RELEASE_VERSION" >> "$GITHUB_ENV"
npm version "$PRE_RELEASE_VERSION" --no-git-tag-version
- name: Build project
run: pnpm run build
- name: Run tests
run: pnpm run test
- name: Publish pre-release to npm
run: npm publish --tag beta --access public
- name: Create GitHub pre-release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${PRE_RELEASE_VERSION}" \
--title "Pre-release v${PRE_RELEASE_VERSION}" \
--notes "Pre-release from develop branch.
- Commit: ${{ github.sha }}
- Branch: ${{ github.ref_name }}
Install with:
\`\`\`bash
npm install -g @hackmd/hackmd-cli@beta
\`\`\`" \
--prerelease