|
7 | 7 | workflow_dispatch: |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - release: |
11 | | - name: Release / Node ${{ matrix.node }} |
12 | | - strategy: |
13 | | - matrix: |
14 | | - node: ['14'] |
15 | | - |
16 | | - runs-on: ubuntu-latest |
17 | | - |
| 10 | + semantic-release: |
| 11 | + name: Release |
| 12 | + runs-on: ubuntu-20.04 |
| 13 | + outputs: |
| 14 | + new-release-published: ${{ steps.semantic-release.outputs.new_release_published }} |
| 15 | + new-release-version: ${{ steps.semantic-release.outputs.new_release_version }} |
18 | 16 | steps: |
19 | 17 | - uses: actions/checkout@v2 |
20 | 18 |
|
21 | | - - name: Set up Node |
22 | | - uses: actions/setup-node@v2 |
| 19 | + - uses: actions/setup-node@v2 |
23 | 20 | with: |
24 | | - node-version: ${{ matrix.node }} |
| 21 | + node-version: "14" |
25 | 22 |
|
26 | 23 | - run: | |
27 | | - npm ci |
| 24 | + npm clean-install |
28 | 25 | npm run build |
29 | 26 |
|
30 | | - - name: Get version before |
31 | | - run: echo "VERSION_BEFORE=$(curl -s https://api.github.com/repos/supabase/postgres-meta/releases/latest | jq .name -r)" >> $GITHUB_ENV |
32 | | - |
33 | | - - name: Release on GitHub |
34 | | - run: npx semantic-release |
| 27 | + - id: semantic-release |
| 28 | + uses: cycjimmy/semantic-release-action@v2 |
| 29 | + with: |
| 30 | + semantic_version: 17 |
35 | 31 | env: |
36 | 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
37 | 33 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
38 | 34 |
|
39 | | - - name: Get version after |
40 | | - run: echo "VERSION_AFTER=$(curl -s https://api.github.com/repos/supabase/postgres-meta/releases/latest | jq .name -r)" >> $GITHUB_ENV |
41 | | - |
42 | | - - name: Check version difference |
43 | | - run: | |
44 | | - if [ ${{ env.VERSION_BEFORE }} = ${{ env.VERSION_AFTER }} ]; then |
45 | | - echo 0 > has-new-release |
46 | | - else |
47 | | - echo 1 > has-new-release |
48 | | - fi |
49 | | -
|
50 | | - - uses: actions/upload-artifact@v1 |
51 | | - with: |
52 | | - name: has-new-release |
53 | | - path: has-new-release |
54 | | - |
55 | 35 | upload: |
56 | | - name: Upload / Node ${{ matrix.node }} |
57 | | - |
| 36 | + name: Upload assets to GitHub Releases |
58 | 37 | needs: |
59 | | - - release |
60 | | - |
61 | | - strategy: |
62 | | - matrix: |
63 | | - node: ['14'] |
64 | | - |
65 | | - runs-on: ubuntu-latest |
66 | | - |
| 38 | + - semantic-release |
| 39 | + if: needs.semantic-release.outputs.new-release-published == 'true' |
| 40 | + runs-on: ubuntu-20.04 |
67 | 41 | steps: |
68 | | - - uses: actions/download-artifact@v1 |
69 | | - with: |
70 | | - name: has-new-release |
71 | | - |
72 | | - - name: Check for new release |
73 | | - run: echo "HAS_NEW_RELEASE=$(cat has-new-release/has-new-release)" >> $GITHUB_ENV |
74 | | - |
75 | 42 | - uses: actions/checkout@v2 |
76 | | - if: env.HAS_NEW_RELEASE == 1 |
77 | 43 |
|
78 | | - - uses: actions/cache@v1 |
79 | | - if: env.HAS_NEW_RELEASE == 1 |
| 44 | + - uses: actions/setup-node@v2 |
80 | 45 | with: |
81 | | - path: ~/.npm |
82 | | - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
83 | | - restore-keys: | |
84 | | - ${{ runner.os }}-node- |
85 | | -
|
86 | | - - name: Set up Node |
87 | | - if: env.HAS_NEW_RELEASE == 1 |
88 | | - uses: actions/setup-node@v2 |
89 | | - with: |
90 | | - node-version: ${{ matrix.node }} |
| 46 | + node-version: "14" |
91 | 47 |
|
92 | 48 | - name: Prepare release |
93 | | - if: env.HAS_NEW_RELEASE == 1 |
94 | 49 | run: | |
95 | | - npm ci |
| 50 | + npm clean-install |
96 | 51 | npm run pkg |
97 | | - tar -czvf postgres-meta-linux.tar.gz -C ./bin postgres-meta-linux |
98 | | - tar -czvf postgres-meta-macos.tar.gz -C ./bin postgres-meta-macos |
99 | | - tar -czvf postgres-meta-windows.tar.gz -C ./bin postgres-meta-win.exe |
| 52 | + tar -czvf postgres-meta-${{ needs.semantic-release.outputs.new-release-version }}-x86_64-linux-gnu.tar.gz -C ./bin postgres-meta-linux |
| 53 | + tar -czvf postgres-meta-${{ needs.semantic-release.outputs.new-release-version }}-x86_64-apple-darwin.tar.gz -C ./bin postgres-meta-macos |
| 54 | + tar -czvf postgres-meta-${{ needs.semantic-release.outputs.new-release-version }}-x86_64-pc-windows.tar.gz -C ./bin postgres-meta-win.exe |
100 | 55 |
|
101 | | - - name: Get upload url |
102 | | - if: env.HAS_NEW_RELEASE == 1 |
103 | | - run: echo "UPLOAD_URL=$(curl -s https://api.github.com/repos/supabase/postgres-meta/releases/latest | jq .upload_url -r)" >> $GITHUB_ENV |
104 | | - |
105 | | - - name: Upload linux release asset |
106 | | - if: env.HAS_NEW_RELEASE == 1 |
107 | | - uses: actions/upload-release-asset@v1 |
108 | | - env: |
109 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + - uses: softprops/action-gh-release@v1 |
110 | 57 | with: |
111 | | - upload_url: ${{ env.UPLOAD_URL }} |
112 | | - asset_path: ./postgres-meta-linux.tar.gz |
113 | | - asset_name: postgres-meta-linux.tar.gz |
114 | | - asset_content_type: application/gzip |
| 58 | + files: postgres-meta-*.tar.gz |
115 | 59 |
|
116 | | - - name: Upload macos release asset |
117 | | - if: env.HAS_NEW_RELEASE == 1 |
118 | | - uses: actions/upload-release-asset@v1 |
119 | | - env: |
120 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
121 | | - with: |
122 | | - upload_url: ${{ env.UPLOAD_URL }} |
123 | | - asset_path: ./postgres-meta-macos.tar.gz |
124 | | - asset_name: postgres-meta-macos.tar.gz |
125 | | - asset_content_type: application/gzip |
126 | | - |
127 | | - - name: Upload windows release asset |
128 | | - if: env.HAS_NEW_RELEASE == 1 |
129 | | - uses: actions/upload-release-asset@v1 |
130 | | - env: |
131 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + docker: |
| 61 | + name: Release on Docker Hub |
| 62 | + needs: |
| 63 | + - semantic-release |
| 64 | + if: needs.semantic-release.outputs.new-release-published == 'true' |
| 65 | + runs-on: ubuntu-20.04 |
| 66 | + steps: |
| 67 | + - uses: docker/setup-qemu-action@v1 |
132 | 68 | with: |
133 | | - upload_url: ${{ env.UPLOAD_URL }} |
134 | | - asset_path: ./postgres-meta-windows.tar.gz |
135 | | - asset_name: postgres-meta-windows.tar.gz |
136 | | - asset_content_type: application/gzip |
| 69 | + platforms: amd64,arm64 |
137 | 70 |
|
138 | | - - name: Get version |
139 | | - run: echo "VERSION=$(curl -s https://api.github.com/repos/supabase/postgres-meta/releases/latest | jq .name -r)" >> $GITHUB_ENV |
| 71 | + - uses: docker/setup-buildx-action@v1 |
140 | 72 |
|
141 | | - - name: Upload image to Docker Hub |
142 | | - if: env.HAS_NEW_RELEASE == 1 |
143 | | - uses: docker/build-push-action@v1 |
| 73 | + - uses: docker/login-action@v1 |
144 | 74 | with: |
145 | 75 | username: ${{ secrets.DOCKER_USERNAME }} |
146 | 76 | password: ${{ secrets.DOCKER_PASSWORD }} |
147 | | - repository: supabase/postgres-meta |
148 | | - tags: latest,${{ env.VERSION }} |
| 77 | + |
| 78 | + - uses: docker/build-push-action@v2 |
| 79 | + with: |
| 80 | + push: true |
| 81 | + tags: supabase/postgres-meta:latest,supabase/postgres-meta:v${{ needs.semantic-release.outputs.new-release-version }} |
| 82 | + platforms: linux/amd64,linux/arm64 |
0 commit comments