-
-
Notifications
You must be signed in to change notification settings - Fork 18
186 lines (177 loc) · 6.09 KB
/
publish.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: build & upload binaries
on:
push:
tags:
- '*'
branches:
- debug-ci # todo: remove
jobs:
test:
name: run tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- '16.x'
- '18.x'
- '20.x'
- '22.x'
postgis-docker-tag:
- '14-3.4-alpine'
- '15-3.4-alpine'
- '16-3.4-alpine'
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: install sponge (moreutils)
run: sudo apt install -y moreutils
- name: install & start PostgreSQL with PostGIS
# todo: currently, it uses mdillon, which doesn't have PostgreSQL 14
# uses: huaxk/postgis-action@v1
# with:
# postgresql version: '${{ matrix.postgis-docker-tag }}'
# postgresql password: password
# postgresql user: postgres
# postgresql db: postgres
run: |
docker run -d \
-e POSTGRES_USER=$PGUSER -e POSTGRES_PASSWORD=$PGPASSWORD -e POSTGRES_DB=$PGDATABASE \
-p 5432:5432 postgis/postgis:${{ matrix.postgis-docker-tag }} \
-c timezone=Europe/Berlin
env:
PGUSER: postgres
PGPASSWORD: password
PGDATABASE: postgres
- run: npm install
- run: npm run lint
- name: npm test
run : npm test
env:
PGHOST: localhost
PGPORT: '5432'
PGUSER: postgres
PGPASSWORD: password
PGDATABASE: postgres
binaries:
name: build binaries & publish as GitHub release
needs: [test]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup Node
uses: actions/setup-node@v4
with:
node-version: 16.x
- run: npm install
- name: build binaries
run: npm run build-binaries
- name: compress binaries
run: |
set -e
gzip --best -k dist/*
ls -lh dist
- name: create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: gtfs-via-postgres@${{ github.ref }}
- name: upload x64 macOS binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-macos-x64
asset_name: gtfs-via-postgres-macos-x64
asset_content_type: application/octet-stream
- name: upload compressed x64 macOS binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-macos-x64.gz
asset_name: gtfs-via-postgres-macos-x64.gz
asset_content_type: application/octet-stream
- name: upload arm64 macOS binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-macos-arm64
asset_name: gtfs-via-postgres-macos-arm64
asset_content_type: application/octet-stream
- name: upload compressed arm64 macOS binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-macos-arm64.gz
asset_name: gtfs-via-postgres-macos-arm64.gz
asset_content_type: application/octet-stream
- name: upload x64 Linux binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-linux-x64
asset_name: gtfs-via-postgres-linux-x64
asset_content_type: application/octet-stream
- name: upload compressed x64 Linux binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-linux-x64.gz
asset_name: gtfs-via-postgres-linux-x64.gz
asset_content_type: application/octet-stream
- name: upload arm64 Linux binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-linux-arm64
asset_name: gtfs-via-postgres-linux-arm64
asset_content_type: application/octet-stream
- name: upload compressed arm64 Linux binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/gtfs-via-postgres-linux-arm64.gz
asset_name: gtfs-via-postgres-linux-arm64.gz
asset_content_type: application/octet-stream
docker-image:
name: build & publish Docker image
needs: [test]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: use Docker buildx
uses: docker/setup-buildx-action@v4
- name: build Docker image & push to Docker Hub
uses: docker/build-push-action@v6
with:
push: true
tags: |
ghcr.io/public-transport/gtfs-via-postgres:latest
ghcr.io/public-transport/gtfs-via-postgres:4
# https://github.com/docker/build-push-action/blob/9472e9021074a3cb3279ba431598b8836d40433f/docs/advanced/cache.md#github-cache
# https://github.com/moby/buildkit#registry-push-image-and-cache-separately
cache-from: type=gha
cache-to: type=gha,mode=max,oci-mediatypes=true,compression=zstd