Skip to content

Commit c6340e3

Browse files
committed
Add Github workflow.
1 parent 206b300 commit c6340e3

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

.github/workflows/main.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
-
15+
name: Checkout
16+
uses: actions/checkout@v2
17+
-
18+
name: Test building snapshot
19+
run: docker-compose run --rm chirpstack-rest-api make snapshot
20+
21+
dist:
22+
needs: test
23+
runs-on: ubuntu-latest
24+
if: startsWith(github.ref, 'refs/tags/v')
25+
steps:
26+
-
27+
name: Checkout
28+
uses: actions/checkout@v2
29+
-
30+
name: Configure AWS credentials
31+
uses: aws-actions/configure-aws-credentials@v1
32+
with:
33+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
34+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
35+
aws-region: eu-west-1
36+
-
37+
name: Build distributable binaries
38+
run: docker-compose run --rm chirpstack-rest-api make dist
39+
-
40+
name: Upload binaries to S3
41+
if: startsWith(github.ref, 'refs/tags/v')
42+
run: |
43+
aws s3 sync dist/upload s3://builds.loraserver.io/chirpstack-rest-api
44+
45+
docker:
46+
needs: test
47+
runs-on: ubuntu-latest
48+
if: startsWith(github.ref, 'refs/tags/v')
49+
steps:
50+
-
51+
name: Checkout
52+
uses: actions/checkout@v2
53+
-
54+
name: Docker meta
55+
id: meta
56+
uses: docker/metadata-action@v3
57+
with:
58+
images: |
59+
chirpstack/${{ github.event.repository.name }}
60+
tags: |
61+
type=semver,pattern={{version}}
62+
type=semver,pattern={{major}}
63+
type=semver,pattern={{major}}.{{minor}}
64+
-
65+
name: Set up QEMU
66+
uses: docker/setup-qemu-action@v1
67+
-
68+
name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@v1
70+
-
71+
name: Login to DockerHub
72+
uses: docker/login-action@v1
73+
with:
74+
username: ${{ secrets.DOCKERHUB_USERNAME }}
75+
password: ${{ secrets.DOCKERHUB_TOKEN }}
76+
-
77+
name: Build and push
78+
id: docker_build
79+
uses: docker/build-push-action@v2
80+
with:
81+
platforms: linux/amd64,linux/arm64
82+
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}
85+
-
86+
name: Image digest
87+
run: echo ${{ steps.docker_build.outputs.digest }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# excluded hidden files
55
!.gitmodules
66
!.goreleaser.yaml
7+
!.github
78

89
# builds
910
/build

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ build:
1111

1212
dist:
1313
goreleaser
14+
mkdir -p dist/upload
15+
mv dist/*.tar.gz dist/upload
16+
mv dist/*.deb dist/upload
17+
mv dist/*.rpm dist/upload
1418

1519
snapshot:
1620
goreleaser --snapshot

0 commit comments

Comments
 (0)