-
-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (123 loc) · 5.13 KB
/
Copy pathrelease.yml
File metadata and controls
138 lines (123 loc) · 5.13 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
135
136
137
138
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g. v3.0.0)'
required: true
type: string
permissions:
contents: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:11
env:
MARIADB_ROOT_PASSWORD: root_password
MARIADB_DATABASE: deploy_center_test
MARIADB_USER: deploycenter
MARIADB_PASSWORD: deploycenter_test_password
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=10
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=10
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: 🔨 Build project
run: npm run build
- name: 🧪 Run tests
run: npm test
env:
# setupTestDb.ts loads .env.test with `override: true`; service
# containers above are configured to match .env.test exactly.
NODE_ENV: test
- name: 📝 Extract version from tag
id: get_version
run: |
# On `push` over a tag, GITHUB_REF is `refs/tags/vX.Y.Z`.
# On `workflow_dispatch`, the user supplies the tag explicitly.
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${GITHUB_REF#refs/tags/}"
fi
VERSION="${TAG#v}"
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Resolved tag=${TAG} version=${VERSION}"
- name: 📋 Extract changelog
id: changelog
run: |
# Extract changelog for this version
VERSION="${{ steps.get_version.outputs.VERSION }}"
sed -n "/## \[$VERSION\]/,/## \[/p" docs/CHANGELOG.md | sed '$d' > RELEASE_NOTES.md
echo "Release notes extracted for version $VERSION"
- name: 📦 Create distribution archive
run: |
# Create dist folder with production files
mkdir -p release/deploy-center-${{ steps.get_version.outputs.VERSION }}
cp -r dist release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp -r docs release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp -r examples release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp -r scripts release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp -r LICENSES release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp package.json release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp package-lock.json release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp .env.example release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp ecosystem.config.js release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp README.md release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp LICENSE.md release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp CONTRIBUTING.md release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp CODE_OF_CONDUCT.md release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp SECURITY.md release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
cp SUPPORT.md release/deploy-center-${{ steps.get_version.outputs.VERSION }}/
# Create archive
cd release
tar -czf deploy-center-v${{ steps.get_version.outputs.VERSION }}.tar.gz deploy-center-${{ steps.get_version.outputs.VERSION }}
zip -r deploy-center-v${{ steps.get_version.outputs.VERSION }}.zip deploy-center-${{ steps.get_version.outputs.VERSION }}
cd ..
- name: 🚀 Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.TAG }}
body_path: RELEASE_NOTES.md
files: |
release/deploy-center-v${{ steps.get_version.outputs.VERSION }}.tar.gz
release/deploy-center-v${{ steps.get_version.outputs.VERSION }}.zip
draft: false
prerelease: false
generate_release_notes: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: ✅ Release created
run: |
echo "✅ Release v${{ steps.get_version.outputs.VERSION }} created successfully!"
echo "📦 Download: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.get_version.outputs.VERSION }}"