-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (111 loc) · 4.41 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
name: 'Release'
on:
workflow_call:
defaults:
run:
shell: bash
permissions:
contents: write
packages: write
jobs:
release-node:
name: 'Semantic Release'
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.set-version.outputs.RELEASE_VERSION }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: 'Obtain Github App token'
id: app-token
uses: getsentry/action-github-app-token@v3.0.0
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
- name: 'Clean install dependencies'
run: npm ci
- name: 'Build'
run: npm run build
- name: 'Execute Semantic Release'
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set release version number
id: set-version
run: |
RELEASE_VERSION=$( git describe --tags "${{ github.sha }}")
echo "RELEASE_VERSION=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
release-docker:
name: 'Release Docker image'
needs: release-node
runs-on: ubuntu-latest
if: ${{ ( github.ref_name == 'main' ) }}
env:
IMAGE_NAME: ${{ github.repository }}
environment:
name: production
url: https://studio-api.cheqd.net
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
install: true
version: latest
- name: Install DigitalOcean CLI
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DOCR
run: doctl registry login --expiry-seconds 600
- name: Configure Docker image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}
registry.digitalocean.com/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
type=semver,pattern={{version}},value=${{ needs.release-node.outputs.RELEASE_VERSION }}
type=raw,value=production-latest
type=sha,format=long
labels: |
org.opencontainers.image.description="Cheqd Studio"
org.opencontainers.image.source="https://github.com/cheqd/studio"
org.opencontainers.image.vendor="Cheqd Foundation Limited"
org.opencontainers.image.created={{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}
org.opencontainers.image.documentation="https://docs.cheqd.io/identity"
- name: Build image with labels
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64
load: true
target: runner
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=min
- name: Push image to GitHub Container Registry
run: docker image push --all-tags ghcr.io/${{ env.IMAGE_NAME }}
- name: Push image to DigitalOcean Container Registry
run: docker image push --all-tags registry.digitalocean.com/${{ env.IMAGE_NAME }}