-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (96 loc) · 3.56 KB
/
release.yml
File metadata and controls
110 lines (96 loc) · 3.56 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
name: Publish to npm and Deploy
on:
pull_request:
types:
- closed
branches:
- main
jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
id-token: write
packages: write
pull-requests: write
steps:
- name: Generate token from GitHub App
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
fetch-depth: 0
persist-credentials: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Determine version bump
id: version_type
run: |
if [[ "${{ github.event.pull_request.title }}" == *"major"* ]]; then
echo "BUMP_TYPE=major" >> $GITHUB_ENV
elif [[ "${{ github.event.pull_request.title }}" == *"minor"* ]]; then
echo "BUMP_TYPE=minor" >> $GITHUB_ENV
else
echo "BUMP_TYPE=patch" >> $GITHUB_ENV
fi
- name: Configure Git
run: |
git config user.name "TODOvue-release-bot[bot]"
git config user.email "TODOvue-release-bot[bot]@users.noreply.github.com"
git config url."https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/".insteadOf "https://github.com/"
- name: Bump version and push
id: bump
run: |
npm version $BUMP_TYPE -m "chore(release): 🔥 v%s [skip ci]"
NEW_VERSION=$(node -p "require('./package.json').version")
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
git push origin main --follow-tags
env:
GIT_AUTHOR_NAME: "TODOvue-release-bot[bot]"
GIT_AUTHOR_EMAIL: "TODOvue-release-bot[bot]@users.noreply.github.com"
GIT_COMMITTER_NAME: "TODOvue-release-bot[bot]"
GIT_COMMITTER_EMAIL: "TODOvue-release-bot[bot]@users.noreply.github.com"
- name: Build package
run: npm run build
- name: Publish to npm
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate_token.outputs.token }}
script: |
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${{ steps.bump.outputs.NEW_VERSION }}`,
name: `v${{ steps.bump.outputs.NEW_VERSION }}`,
body: 'For stable releases, please refer to [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.',
draft: false,
prerelease: false
});
- name: Build Demo Website
run: npm run build:demo
- name: Deploy TODOvue UI
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./dist-demo/
server-dir: ${{ secrets.FTP_DIR }}
dangerous-clean-slate: true