-
Notifications
You must be signed in to change notification settings - Fork 10
149 lines (137 loc) · 5.32 KB
/
release.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Release
on:
pull_request:
paths-ignore:
- 'docs/**'
push:
branches:
- master
paths-ignore:
- 'docs/**'
release:
types:
- created
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DEBIAN_FRONTEND: noninteractive
LANG: C.UTF-8
jobs:
build_docker_image:
name: Build docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker build -t convertit:latest .
- name: Upload image
uses: ishworkh/docker-image-artifact-upload@v1
with:
image: "convertit:latest"
build_deb_22_04:
name: Build 22.04 package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare debian 22.04 versioning
run: |
sed -i 's/+dev/.ubuntu22.04~dev'$GITHUB_RUN_ID'/' debian/changelog
sed -i 's/convertit (\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(.*\)) RELEASED;/convertit (\1.ubuntu22.04\2) jammy;/' debian/changelog
- name: Building package debian 22.04
run: |
DISTRO=ubuntu:jammy make build_deb
cp ./dpkg/*.deb /home/runner/work/convertit/
- name: Archive package artifact
uses: actions/upload-artifact@v3
with:
name: debian-22.04
path: |
/home/runner/work/Geotrek-admin/*.deb
build_deb_20_04:
name: Build 20.04 package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare debian 20.04 versioning
run: |
sed -i 's/+dev/.ubuntu20.04~dev'$GITHUB_RUN_ID'/' debian/changelog
sed -i 's/convertit (\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(.*\)) RELEASED;/convertit (\1.ubuntu20.04\2) focal;/' debian/changelog
- name: Building package debian 18.04
run: |
DISTRO=ubuntu:focal make build_deb
cp ./dpkg/*.deb /home/runner/work/convertit/
- name: Archive package artifact
uses: actions/upload-artifact@v3
with:
name: debian-20.04
path: |
/home/runner/work/Geotrek-admin/*.deb
deploy:
name: Publish (on release only)
runs-on: ubuntu-latest
needs: [ build_docker_image, build_deb_22_04, build_deb_20_04 ]
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
steps:
- uses: actions/checkout@v3
- name: Download 22.04 debian artifact
uses: actions/download-artifact@v3
with:
name: debian-22.04
- name: Download 20.04 debian artifact
uses: actions/download-artifact@v3
with:
name: debian-20.04
- name: Download docker image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "convertit:latest"
- name: Attach debian packages as release binaries
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: '*.deb'
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish Docker image (v2 and latest)
run: |
if [[ "${{ github.ref }}" == *"dev"* ]]; then
export DOCKER_TAG=dev
else
docker tag convertit:latest makinacorpus/convertit:$(cat VERSION)
docker push makinacorpus/convertit:$(cat VERSION)
export DOCKER_TAG=latest
fi
docker tag convertit:latest makinacorpus/convertit:$DOCKER_TAG
docker push makinacorpus/convertit:$DOCKER_TAG
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: Publish debian packages
run: |
if [[ "${{ github.ref }}" == *"dev"* ]]; then
export DEB_COMPONENT=dev
else
export DEB_COMPONENT=main
fi
echo "${{ github.ref }} : Publishing as $DEB_COMPONENT package"
scp -P ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no /home/runner/work/convertit/convertit/convertit_*_amd64.deb ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/srv/packages/incoming/$DEB_COMPONENT/
if [[ "${{ github.ref }}" == *"dev"* ]]; then
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make bionic_dev -C /srv/packages
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make focal_dev -C /srv/packages
else
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make bionic_main -C /srv/packages
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make focal_main -C /srv/packages
fi