-
Notifications
You must be signed in to change notification settings - Fork 3
161 lines (159 loc) · 6.25 KB
/
release.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Release
on:
workflow_dispatch:
push:
branches:
- master
env:
NODE_VERSION: '16.16.0'
jobs:
CurrentTag:
runs-on: ubuntu-latest
outputs:
CURRENT_TAG: ${{ steps.save-current-tag.outputs.CURRENT_TAG }}
steps:
- name: Checkout develop
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
ref: develop
- name: Reset branch
run: |
git fetch origin master:master
git reset --hard master
- name: Get current tag
id: current-tag
uses: WyriHaximus/github-action-get-previous-tag@385a2a0b6abf6c2efeb95adfac83d96d6f968e0c # v1.3.0
with:
fallback: 1.0.0
env:
GITHUB_TOKEN: ${{ secrets.SONIA_BOT_GH_TOKEN }}
- name: Save current tag
id: save-current-tag
run: echo 'CURRENT_TAG=${{ steps.current-tag.outputs.tag }}' >> $GITHUB_OUTPUT
Release:
runs-on: ubuntu-latest
needs: [CurrentTag]
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
env:
cache-name: cache-node-modules
with:
path: |
node_modules
documentation/node_modules
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
npm ci
cd documentation
npm ci
- name: Build
run: npm run build
env:
CI: true
- name: Release
run: npm run semver
env:
GITHUB_TOKEN: ${{ secrets.SONIA_BOT_GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
Website:
runs-on: ubuntu-latest
needs: [CurrentTag, Release]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
# Since the previous job (Release) is doing a commit containing the new website changelog
# We need to specify exactly the ref so that we are sure to load the last commit from the branch
ref: master
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
env:
cache-name: cache-node-modules
with:
path: |
node_modules
documentation/node_modules
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
npm ci
cd documentation
npm ci
- name: Build website
run: |
cd documentation
npm run build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
with:
github_token: ${{ secrets.SONIA_BOT_GH_TOKEN }}
publish_dir: ./documentation/build
user_name: ${{ secrets.GIT_COMMITTER_NAME }}
user_email: ${{ secrets.GIT_COMMITTER_EMAIL }}
PR:
runs-on: ubuntu-latest
needs: [CurrentTag, Release]
steps:
- name: Checkout develop
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
ref: develop
- name: Reset branch
run: |
git fetch origin master:master
git reset --hard master
- name: Get latest tag
id: latest-tag
uses: WyriHaximus/github-action-get-previous-tag@385a2a0b6abf6c2efeb95adfac83d96d6f968e0c # v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.SONIA_BOT_GH_TOKEN }}
- name: Show current tag
run: echo 'The current tag is ${{ needs.CurrentTag.outputs.CURRENT_TAG }}'
- name: Has same tag
if: needs.CurrentTag.outputs.CURRENT_TAG == steps.latest-tag.outputs.tag
run: echo 'The current tag did not change'
- name: Has new tag
if: needs.CurrentTag.outputs.CURRENT_TAG != steps.latest-tag.outputs.tag
run: echo 'The current tag is not the same after the release. A new tag has been created'
- name: Create PR from master to develop
if: needs.CurrentTag.outputs.CURRENT_TAG != steps.latest-tag.outputs.tag
uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # v4
with:
token: ${{ secrets.SONIA_BOT_GH_TOKEN }}
title: 'chore(develop): merge master into develop due to new version ${{ steps.latest-tag.outputs.tag }}'
branch: feature/merge-master-into-develop
assignees: C0ZEN
labels: 'auto-merge :ok:'
commit-message: 'chore(develop): merge master into develop'
committer: ${{ secrets.GIT_COMMITTER_NAME }} <${{ secrets.GIT_COMMITTER_EMAIL }}>
author: ${{ secrets.GIT_AUTHOR_NAME }} <${{ secrets.GIT_AUTHOR_EMAIL }}>
body: |
:tada: This PR was generated after the creation of the version ${{ steps.latest-tag.outputs.tag }} :tada:
The release is available on:
- [npm package (@latest dist-tag)](https://www.npmjs.com/package/@sonia-corporation/stale/v/${{ steps.latest-tag.outputs.tag }})
- [GitHub release](https://github.com/Sonia-corporation/stale/releases/tag/${{ steps.latest-tag.outputs.tag }})
Your **@Sonia-corporation-bot** :rocket: