]> Untitled Git - lemmy.git/blob - .drone.yml
publish to crates.io with normal release script
[lemmy.git] / .drone.yml
1 ---
2 kind: pipeline
3 name: amd64
4
5 platform:
6   os: linux
7   arch: amd64
8
9 steps:
10
11   - name: prepare repo
12     image: ekidd/rust-musl-builder:1.51.0
13     user: root
14     commands:
15       - chown 1000:1000 . -R
16       - git fetch --tags
17
18   - name: check formatting
19     image: rustdocker/rust:nightly
20     commands:
21       - /root/.cargo/bin/cargo fmt -- --check
22
23   - name: cargo clippy
24     image: ekidd/rust-musl-builder:1.51.0
25     commands:
26       - cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity -D clippy::dbg_macro
27       - cargo clippy --workspace -- -D clippy::unwrap_used
28
29   - name: cargo test
30     image: ekidd/rust-musl-builder:1.51.0
31     environment:
32       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
33       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
34       RUST_BACKTRACE: 1
35       RUST_TEST_THREADS: 1
36     commands:
37       - sudo apt-get update
38       - sudo apt-get -y install --no-install-recommends postgresql-client
39       - cargo test --workspace --no-fail-fast
40
41   - name: cargo build
42     image: ekidd/rust-musl-builder:1.51.0
43     commands:
44       - cargo build
45       - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
46
47   - name: run federation tests
48     image: node:15-alpine3.12
49     environment:
50       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
51       DO_WRITE_HOSTS_FILE: 1
52     commands:
53       - apk add bash curl postgresql-client
54       - bash api_tests/prepare-drone-federation-test.sh
55       - cd api_tests/
56       - yarn
57       - yarn api-test
58
59   - name: publish dev docker image
60     image: plugins/docker
61     settings:
62       dockerfile: docker/prod/Dockerfile
63       username:
64         from_secret: docker_username
65       password:
66         from_secret: docker_password
67       repo: dessalines/lemmy
68       tags:
69         - dev-linux-amd64
70     when:
71       ref:
72         - refs/heads/main
73
74   - name: publish dev docker manifest
75     image: plugins/manifest
76     settings:
77       username:
78         from_secret: docker_username
79       password:
80         from_secret: docker_password
81       target: "dessalines/lemmy:dev"
82       template: "dessalines/lemmy:dev-OS-ARCH"
83       platforms:
84         - linux/amd64
85         - linux/arm64
86       ignore_missing: true
87     when:
88       ref:
89         - refs/heads/main
90
91   - name: publish release docker image
92     image: plugins/docker
93     settings:
94       dockerfile: docker/prod/Dockerfile
95       username:
96         from_secret: docker_username
97       password:
98         from_secret: docker_password
99       repo: dessalines/lemmy
100       auto_tag: true
101       auto_tag_suffix: linux-amd64
102     when:
103       ref:
104         - refs/tags/*
105
106   - name: publish release docker manifest
107     image: plugins/manifest
108     settings: 
109       username:
110         from_secret: docker_username
111       password:
112         from_secret: docker_password
113       target: "dessalines/lemmy:${DRONE_TAG}"
114       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
115       platforms:
116         - linux/amd64
117         - linux/arm64
118       ignore_missing: true
119     when:
120       ref:
121         - refs/tags/*
122
123   # using https://github.com/pksunkara/cargo-workspaces
124   - name: publish to crates.io
125     image: rust:1.51-slim-buster
126     commands:
127       - cargo install cargo-workspaces
128       - cp -r migrations crates/db_queries/
129       - cargo workspaces publish --no-git-commit --allow-branch main --yes custom "${DRONE_TAG}"
130     when:
131       ref:
132         - refs/tags/*
133
134 services:
135   - name: database
136     image: postgres:12-alpine
137     environment:
138       POSTGRES_USER: lemmy
139       POSTGRES_PASSWORD: password
140
141 ---
142 kind: pipeline
143 name: arm64
144
145 platform:
146   os: linux
147   arch: arm64
148
149 steps:
150
151   - name: prepare repo
152     image: rust:1.51-slim-buster
153     user: root
154     commands:
155       - chown 1000:1000 . -R
156       - apt update
157       - apt install --no-install-recommends --yes git
158       - git fetch --tags
159
160   - name: cargo test
161     image: rust:1.51-slim-buster
162     environment:
163       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
164       LEMMY_CONFIG_LOCATION: ../../config/config.hjson
165       RUST_BACKTRACE: 1
166       RUST_TEST_THREADS: 1
167     commands:
168       - apt-get update
169       - apt-get -y install --no-install-recommends postgresql-client libssl-dev pkg-config libpq-dev
170       - cargo test --workspace --no-fail-fast
171       - cargo build
172
173   # Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
174   - name: cargo build
175     image: rust:1.51-slim-buster
176     commands:
177       - apt-get update
178       - apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
179       - cargo build
180       - mv target/debug/lemmy_server target/lemmy_server
181
182   - name: run federation tests
183     image: node:15-buster-slim
184     environment:
185       LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432
186       DO_WRITE_HOSTS_FILE: 1
187     commands:
188       - mkdir -p /usr/share/man/man1 /usr/share/man/man7
189       - apt-get update
190       - apt-get -y install --no-install-recommends bash curl libssl-dev pkg-config libpq-dev postgresql-client libc6-dev
191       - bash api_tests/prepare-drone-federation-test.sh
192       - cd api_tests/
193       - yarn
194       - yarn api-test
195
196   - name: publish dev docker image
197     image: plugins/docker
198     settings:
199       dockerfile: docker/prod/Dockerfile.arm
200       username:
201         from_secret: docker_username
202       password:
203         from_secret: docker_password
204       repo: dessalines/lemmy
205       tags:
206         - dev-linux-arm64
207     when:
208       ref:
209         - refs/heads/main
210
211   - name: publish dev docker manifest
212     image: plugins/manifest
213     settings:
214       username:
215         from_secret: docker_username
216       password:
217         from_secret: docker_password
218       target: "dessalines/lemmy:dev"
219       template: "dessalines/lemmy:dev-OS-ARCH"
220       platforms:
221         - linux/amd64
222         - linux/arm64
223       ignore_missing: true
224     when:
225       ref:
226         - refs/heads/main
227
228   - name: publish release docker image
229     image: plugins/docker
230     settings:
231       dockerfile: docker/prod/Dockerfile.arm
232       username:
233         from_secret: docker_username
234       password:
235         from_secret: docker_password
236       repo: dessalines/lemmy
237       auto_tag: true
238       auto_tag_suffix: linux-arm64
239     when:
240       ref:
241         - refs/tags/*
242
243   - name: publish release docker manifest
244     image: plugins/manifest
245     settings: 
246       username:
247         from_secret: docker_username
248       password:
249         from_secret: docker_password
250       target: "dessalines/lemmy:${DRONE_TAG}"
251       template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
252       platforms:
253         - linux/amd64
254         - linux/arm64
255       ignore_missing: true
256     when:
257       ref:
258         - refs/tags/*
259
260 services:
261   - name: database
262     image: postgres:12-alpine
263     environment:
264       POSTGRES_USER: lemmy
265       POSTGRES_PASSWORD: password