-
Notifications
You must be signed in to change notification settings - Fork 2
106 lines (89 loc) · 3.23 KB
/
release-management.yml
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
name: Release Management
on:
push:
branches: [main]
jobs:
build_and_test:
name: Build and test
runs-on: ubuntu-20.04
outputs:
version_changed: ${{ steps.check_package_version.outputs.changed }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm test
- name: Check package.json for version change
id: check_package_version
uses: EndBug/version-check@v2
- name: Log when version changed
if: steps.check_package_version.outputs.changed == 'true'
run: 'echo "Version change found in commit ${{ steps.check_package_version.outputs.commit }}! New version: ${{ steps.check_package_version.outputs.version }} (${{ steps.check_package_version.outputs.type }})"'
- name: Log when version unchanged
if: steps.check_package_version.outputs.changed == 'false'
run: 'echo "No version change"'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: assets
path: assets/built
update_release_draft:
name: Update release draft
needs: [build_and_test]
if: needs.build_and_test.outputs.version_changed == 'false'
runs-on: ubuntu-20.04
steps:
- name: Draft release on GitHub
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish_release_draft_on_version_bump:
name: Publish release draft
needs: [build_and_test]
if: needs.build_and_test.outputs.version_changed == 'true'
runs-on: ubuntu-20.04
steps:
- name: Clone repository
uses: actions/checkout@v4
# An existing release draft is published only if there is a version bump in `package.json`.
# Throws an error and breaks the job if called regardless. We check for version changes in the
# `build_and_test` job first so this job is skipped rather than exited with an error.
- name: Publish matching GitHub release draft
id: github_release
uses: JamesMGreene/node-draft-releaser@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
allow_release_name_update: 'false'
- name: Write out the release URL
run: echo "Released at $RELEASE_URL"
env:
RELEASE_URL: ${{ steps.github_release.outputs.release_url }}
deploy_theme:
name: Deploy theme to Ghost cloud
needs: [build_and_test, publish_release_draft_on_version_bump]
if: needs.build_and_test.outputs.version_changed == 'true'
runs-on: ubuntu-20.04
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: assets
path: assets/built
- name: Deploy Ghost theme
uses: TryGhost/action-deploy-theme@v1
with:
api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}
exclude: '.* assets/scss/* dist/* postcss.config.js'