-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
157 lines (133 loc) · 5.6 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
# This is a basic workflow to help you get started with Actions
name: Release
# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
description: "Version to release (if the version contains the beta keyword, we assume it is a pre-release)"
# Default value if no value is explicitly provided
default: ""
# Input has to be provided for the workflow to run
required: true
jobs:
# This workflow contains a single job called "build"
build-all:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set prerelease variable
id: vars
run: |
echo ::set-output name=prerelease::${{ contains(github.event.inputs.version, 'beta') }}
echo ::set-output name=nonPatchRelease::${{ endsWith(github.event.inputs.version, '.0') }}
- name: Log parsed version
run: |
echo "version: ${{github.event.inputs.version}}"
echo "prerelease: ${{ steps.vars.outputs.prerelease }}"
- name: Set git config
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Reuse npm cache folder
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
./node_modules
key: ${{ runner.os }}-npm-rxdb-release-x2-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-npm-rxdb-release-x2-
# Build the docs, only do this if it is not a prerelease.
# TODO move from gitbook to honkit
# https://github.com/honkit/honkit
# so we do not need this
- name: downgrade nodejs for gitbook
if: steps.vars.outputs.prerelease == 'false'
uses: actions/setup-node@v3.8.1
with:
node-version: 13.8.0
- name: Install old node version so it works with the shitty gitbook
if: steps.vars.outputs.prerelease == 'false'
run: |
node -v
npm install
- name: build docs
if: steps.vars.outputs.prerelease == 'false'
run: |
npm run docs:build
- name: Setup Node.js environment
uses: actions/setup-node@v3.8.1
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
- name: install npm dependencies
run: |
node -v
rm -rf node_modules/
npm install
- name: "update version and changelog"
working-directory: "scripts"
run: |
node set-version.js ${{github.event.inputs.version}}
- run: npm run docs:landingpage:build
- run: npm run build
- name: add git tag
run: |
git add .
git status .
git diff package.json
git commit -m ${{github.event.inputs.version}}
git tag ${{github.event.inputs.version}}
- run: npm publish --tag next
if: steps.vars.outputs.prerelease == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm publish
if: steps.vars.outputs.prerelease == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# pull again to make it unlikely that we have a merge conflict.
- run: git pull
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
# must run after the push
# because it otherwise does not know
# about the tag and add the old source code to the release.
# This might be a bug.
- uses: ncipollo/release-action@v1.12.0
with:
prerelease: ${{ steps.vars.outputs.prerelease }}
tag: ${{github.event.inputs.version}}
bodyFile: "./release-body.md"
token: ${{ secrets.GITHUB_TOKEN }}
# @link https://github.com/marketplace/actions/actions-for-discord
- name: Discord notification
# To not spam users too much, we only do this on major and minor releases
if: steps.vars.outputs.prerelease == 'false' && steps.vars.outputs.nonPatchRelease == 'true'
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: "@everyone A new RxDB version has been released: https://github.com/pubkey/rxdb/releases/tag/${{github.event.inputs.version}}"
# @link https://github.com/marketplace/actions/send-tweet-action
- name: Twitter notification
# To not spam users too much, we only do this on major and minor releases
if: steps.vars.outputs.prerelease == 'false' && steps.vars.outputs.nonPatchRelease == 'true'
uses: ethomson/send-tweet-action@v1
with:
status: "A new #RxDB version ${{github.event.inputs.version}} has been released: https://github.com/pubkey/rxdb/releases/tag/${{github.event.inputs.version}}"
consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}