forked from Argus-Labs/world-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (111 loc) · 4.23 KB
/
release.yaml
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
name: Release
## workflow will trigger on below condition,
## except image release that have jobs condition to trigger only on tagging
on:
push:
branches:
- main
tags:
- 'chain/v*.*.*'
- 'relay/nakama/v*.*.*'
env:
REGISTRY_URL: us-docker.pkg.dev
jobs:
chain-release:
name: Chain Image Release
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/chain/v')
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: chain
# Add "id-token" with the intended permissions.
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker images
uses: ScribeMD/[email protected]
with:
key: docker-${{ runner.os }}-${{ hashFiles('chain/Dockerfile') }}
- name: GCP auth
id: auth
uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }}
service_account: ${{ secrets.GCP_WIF_SERVICE_ACCOUNT }}
- name: GCP - Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ env.GCP_PROJECT_ID_PACKAGES }}
- name: Docker - Auth to artifact registry
run: |
gcloud auth configure-docker ${{ env.REGISTRY_URL }}
- name: Docker - Build
run: |
docker build -t chain-local-build:latest .
- name: Docker - Publish Image
run: |
## Construct image_id
IMAGE_ID_CHAIN=${{ env.REGISTRY_URL }}/${{ github.repository_owner }}/${{ github.event.repository.name }}/chain
IMAGE_ID_CHAIN=$(echo $IMAGE_ID_CHAIN | tr '[A-Z]' '[a-z]')
## Get version from tag name (ex: chain/v0.0.0 --> registry/chain:v0.0.0)
## Or use 'latest' when on main branch
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[ "$VERSION" == "main" ] && VERSION=latest
echo "Image to push: $IMAGE_ID_CHAIN:$VERSION"
docker tag chain-local-build:latest $IMAGE_ID_CHAIN:$VERSION
docker push $IMAGE_ID_CHAIN:$VERSION
nakama-release:
name: Nakama Image Release
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/relay/nakama/v')
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: relay/nakama
# Add "id-token" with the intended permissions.
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker images
uses: ScribeMD/[email protected]
with:
key: docker-${{ runner.os }}-${{ hashFiles('relay/nakama/Dockerfile') }}
- name: GCP auth
id: auth
uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }}
service_account: ${{ secrets.GCP_WIF_SERVICE_ACCOUNT }}
- name: GCP - Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ env.GCP_PROJECT_ID_PACKAGES }}
- name: Docker - Auth to artifact registry
run: |
gcloud auth configure-docker ${{ env.REGISTRY_URL }}
- name: Docker - Build
run: |
docker build -t nakama-local-build:latest .
- name: Docker - Publish Image
run: |
## Construct image_id
IMAGE_ID_NAKAMA=${{ env.REGISTRY_URL }}/${{ github.repository_owner }}/${{ github.event.repository.name }}/relay/nakama
IMAGE_ID_NAKAMA=$(echo $IMAGE_ID_NAKAMA | tr '[A-Z]' '[a-z]')
## Get version from tag name (ex: relay/nakama/v0.0.0 --> registry/relay/nakama:v0.0.0)
## Or use 'latest' when on main branch
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[ "$VERSION" == "main" ] && VERSION=latest
echo "Image to push: $IMAGE_ID_NAKAMA:$VERSION"
docker tag nakama-local-build:latest $IMAGE_ID_NAKAMA:$VERSION
docker push $IMAGE_ID_NAKAMA:$VERSION