Skip to content

Commit cc4c392

Browse files
committed
chore: add support for semantic-release
1 parent c280001 commit cc4c392

File tree

2 files changed

+72
-17
lines changed

2 files changed

+72
-17
lines changed

.github/workflows/release.yml

+71-16
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,132 @@ name: Release
22

33
on:
44
push:
5-
tags:
6-
- '*.*.*'
5+
branches:
6+
- master
77

88
jobs:
99
release:
1010
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
1157

1258
strategy:
1359
matrix:
14-
node: ['14']
60+
node: ['12']
1561

1662
runs-on: ubuntu-latest
1763

1864
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+
1972
- uses: actions/checkout@v2
73+
if: env.HAS_NEW_RELEASE == 1
2074

2175
- uses: actions/cache@v1
76+
if: env.HAS_NEW_RELEASE == 1
2277
with:
2378
path: ~/.npm
2479
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
2580
restore-keys: |
2681
${{ runner.os }}-node-
2782
2883
- name: Set up Node
84+
if: env.HAS_NEW_RELEASE == 1
2985
uses: actions/setup-node@v1
3086
with:
3187
node-version: ${{ matrix.node }}
3288

3389
- name: Prepare release
90+
if: env.HAS_NEW_RELEASE == 1
3491
run: |
35-
npm install
92+
npm ci
3693
npm run dist
3794
tar -czvf pg-api-linux.tar.gz -C ./bin start-linux
3895
tar -czvf pg-api-macos.tar.gz -C ./bin start-macos
3996
tar -czvf pg-api-windows.tar.gz -C ./bin start-win.exe
4097
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)
49101

50102
- name: Upload linux release asset
103+
if: env.HAS_NEW_RELEASE == 1
51104
uses: actions/upload-release-asset@v1
52105
env:
53106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54107
with:
55-
upload_url: ${{ steps.create_release.outputs.upload_url }}
108+
upload_url: ${{ env.UPLOAD_URL }}
56109
asset_path: ./pg-api-linux.tar.gz
57110
asset_name: pg-api-linux.tar.gz
58111
asset_content_type: application/gzip
59112

60113
- name: Upload macos release asset
114+
if: env.HAS_NEW_RELEASE == 1
61115
uses: actions/upload-release-asset@v1
62116
env:
63117
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64118
with:
65-
upload_url: ${{ steps.create_release.outputs.upload_url }}
119+
upload_url: ${{ env.UPLOAD_URL }}
66120
asset_path: ./pg-api-macos.tar.gz
67121
asset_name: pg-api-macos.tar.gz
68122
asset_content_type: application/gzip
69123

70124
- name: Upload windows release asset
125+
if: env.HAS_NEW_RELEASE == 1
71126
uses: actions/upload-release-asset@v1
72127
env:
73128
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74129
with:
75-
upload_url: ${{ steps.create_release.outputs.upload_url }}
130+
upload_url: ${{ env.UPLOAD_URL }}
76131
asset_path: ./pg-api-windows.tar.gz
77132
asset_name: pg-api-windows.tar.gz
78-
asset_content_type: application/gzip
133+
asset_content_type: application/gzip

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@supabase/pg-api",
3-
"version": "0.0.9",
3+
"version": "0.0.0",
44
"description": "A RESTful API for managing your Postgres.",
55
"main": "src/start.js",
66
"bin": "src/start.js",

0 commit comments

Comments
 (0)