Skip to content

Commit 4ba3463

Browse files
authored
add ci/cd workflows (#3)
1 parent 139f40f commit 4ba3463

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Cryptography Service
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Install rust
14+
uses: moonrepo/setup-rust@v1
15+
- name: Login to Github registry
16+
uses: docker/login-action@v2
17+
with:
18+
registry: ghcr.io
19+
username: ${{ github.actor }}
20+
password: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
- name: Build and push versioned Docker image
24+
run: |
25+
cd ./services/cryptography
26+
cargo build
27+
cargo test
28+
version=$( cargo pkgid | cut -d '@' -f 2 )
29+
docker build . --tag ghcr.io/${{ github.repository }}/cryptography:$version
30+
docker push ghcr.io/${{ github.repository }}/cryptography:$version
31+
- name: Retag and push latest Docker image
32+
if: github.ref == 'refs/heads/main'
33+
run: |
34+
docker tag ghcr.io/${{ github.repository }}/cryptography:$( cargo pkgid | cut -d '@' -f 2 ) \
35+
ghcr.io/${{ github.repository }}/cryptography:latest
36+
docker push ghcr.io/${{ github.repository }}/cryptography:latest
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Explorer Service
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Login to Github registry
14+
uses: docker/login-action@v2
15+
with:
16+
registry: ghcr.io
17+
username: ${{ github.actor }}
18+
password: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
- name: Build and push versioned Docker image
22+
run: |
23+
version=$( cat ./services/explorer/version.txt )
24+
docker build ./services/explorer --tag ghcr.io/${{ github.repository }}/explorer:$version
25+
docker push ghcr.io/${{ github.repository }}/explorer:$version
26+
- name: Retag and push latest Docker image
27+
if: github.ref == 'refs/heads/main'
28+
run: |
29+
docker tag ghcr.io/${{ github.repository }}/explorer:$( cat ./services/explorer/version.txt ) \
30+
ghcr.io/${{ github.repository }}/explorer:latest
31+
docker push ghcr.io/${{ github.repository }}/explorer:latest

services/cryptography/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cryptography-service"
3-
version = "0.1.0"
3+
version = "1.0.0"
44
edition = "2021"
55

66
[dependencies]

services/cryptography/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# --- Build ---
22

3-
FROM alpine:latest AS builder
3+
FROM alpine:3.21.3 AS builder
44

55
ENV CC=clang
66
ENV CXX=clang++
@@ -17,7 +17,7 @@ RUN cargo build --release
1717

1818
# --- Deploy ---
1919

20-
FROM alpine:latest
20+
FROM alpine:3.21.3
2121

2222
WORKDIR /srv
2323
COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/

services/explorer/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)