@@ -2,77 +2,132 @@ name: Release
2
2
3
3
on :
4
4
push :
5
- tags :
6
- - ' *.*.* '
5
+ branches :
6
+ - master
7
7
8
8
jobs :
9
9
release :
10
10
name : Release / Node ${{ matrix.node }}
11
+ strategy :
12
+ matrix :
13
+ node : ['12']
14
+
15
+ runs-on : ubuntu-latest
16
+
17
+ steps :
18
+ - uses : actions/checkout@v2
19
+
20
+ - name : Set up Node
21
+ uses : actions/setup-node@v1
22
+ with :
23
+ node-version : ${{ matrix.node }}
24
+
25
+ - name : Get version before
26
+ run : echo ::set-env name=VERSION_BEFORE::$(curl -s https://api.github.com/repos/supabase/pg-api/releases/latest | jq .name -r)
27
+
28
+ - name : Release on GitHub
29
+ run : npx semantic-release -p \
30
+ @semantic-release/commit-analyzer \
31
+ @semantic-release/github \
32
+ @semantic-release/release-notes-generator
33
+ env :
34
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
35
+
36
+ - name : Get version after
37
+ run : echo ::set-env name=VERSION_AFTER::$(curl -s https://api.github.com/repos/supabase/pg-api/releases/latest | jq .name -r)
38
+
39
+ - name : Check version difference
40
+ run : |
41
+ if [ ${{ env.VERSION_BEFORE }} = ${{ env.VERSION_AFTER }} ]; then
42
+ echo 0 > has-new-release
43
+ else
44
+ echo 1 > has-new-release
45
+ fi
46
+
47
+ - uses : actions/upload-artifact@v1
48
+ with :
49
+ name : has-new-release
50
+ path : has-new-release
51
+
52
+ upload :
53
+ name : Upload / Node ${{ matrix.node }}
54
+
55
+ needs :
56
+ - release
11
57
12
58
strategy :
13
59
matrix :
14
- node : ['14 ']
60
+ node : ['12 ']
15
61
16
62
runs-on : ubuntu-latest
17
63
18
64
steps :
65
+ - uses : actions/download-artifact@v1
66
+ with :
67
+ name : has-new-release
68
+
69
+ - name : Check for new release
70
+ run : echo ::set-env name=HAS_NEW_RELEASE::$(cat has-new-release/has-new-release)
71
+
19
72
- uses : actions/checkout@v2
73
+ if : env.HAS_NEW_RELEASE == 1
20
74
21
75
- uses : actions/cache@v1
76
+ if : env.HAS_NEW_RELEASE == 1
22
77
with :
23
78
path : ~/.npm
24
79
key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
25
80
restore-keys : |
26
81
${{ runner.os }}-node-
27
82
28
83
- name : Set up Node
84
+ if : env.HAS_NEW_RELEASE == 1
29
85
uses : actions/setup-node@v1
30
86
with :
31
87
node-version : ${{ matrix.node }}
32
88
33
89
- name : Prepare release
90
+ if : env.HAS_NEW_RELEASE == 1
34
91
run : |
35
- npm install
92
+ npm ci
36
93
npm run dist
37
94
tar -czvf pg-api-linux.tar.gz -C ./bin start-linux
38
95
tar -czvf pg-api-macos.tar.gz -C ./bin start-macos
39
96
tar -czvf pg-api-windows.tar.gz -C ./bin start-win.exe
40
97
41
- - name : Create release
42
- id : create_release
43
- uses : actions/create-release@v1
44
- env :
45
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
46
- with :
47
- tag_name : ${{ github.ref }}
48
- release_name : ${{ github.ref }}
98
+ - name : Get upload url
99
+ if : env.HAS_NEW_RELEASE == 1
100
+ run : echo ::set-env name=UPLOAD_URL::$(curl -s https://api.github.com/repos/supabase/pg-api/releases/latest | jq .upload_url -r)
49
101
50
102
- name : Upload linux release asset
103
+ if : env.HAS_NEW_RELEASE == 1
51
104
uses : actions/upload-release-asset@v1
52
105
env :
53
106
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54
107
with :
55
- upload_url : ${{ steps.create_release.outputs.upload_url }}
108
+ upload_url : ${{ env.UPLOAD_URL }}
56
109
asset_path : ./pg-api-linux.tar.gz
57
110
asset_name : pg-api-linux.tar.gz
58
111
asset_content_type : application/gzip
59
112
60
113
- name : Upload macos release asset
114
+ if : env.HAS_NEW_RELEASE == 1
61
115
uses : actions/upload-release-asset@v1
62
116
env :
63
117
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64
118
with :
65
- upload_url : ${{ steps.create_release.outputs.upload_url }}
119
+ upload_url : ${{ env.UPLOAD_URL }}
66
120
asset_path : ./pg-api-macos.tar.gz
67
121
asset_name : pg-api-macos.tar.gz
68
122
asset_content_type : application/gzip
69
123
70
124
- name : Upload windows release asset
125
+ if : env.HAS_NEW_RELEASE == 1
71
126
uses : actions/upload-release-asset@v1
72
127
env :
73
128
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74
129
with :
75
- upload_url : ${{ steps.create_release.outputs.upload_url }}
130
+ upload_url : ${{ env.UPLOAD_URL }}
76
131
asset_path : ./pg-api-windows.tar.gz
77
132
asset_name : pg-api-windows.tar.gz
78
- asset_content_type : application/gzip
133
+ asset_content_type : application/gzip
0 commit comments