-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (131 loc) · 5.01 KB
/
build_tzsafe.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
name: Automatic build and push
#builds docker img and creates tags for the versions
on:
push:
branches:
- dev
- ghostnet
- mainnet
pull_request:
branches:
- dev
- ghostnet
- mainnet
workflow_dispatch:
inputs:
manual_tagging_version:
description: "Create version at current head commit on mainnet branch, specify tag/version bellow (e.g., v1.2.3)"
required: true
default: ""
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
docker:
name: "Docker build"
runs-on: ubuntu-latest
steps:
# setting up the environment
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Testing
- name: Testing code
if: ${{ github.ref == 'refs/heads/ghostnet' }}
uses: actions/setup-node@v4
with:
node-version: "18.x"
run: |
npm ci
npm t
# Build testing
- name: Testing docker build
if: ${{ github.event_name == 'pull_request' && github.ref == 'refs/heads/dev' }}
uses: docker/build-push-action@v4
with:
file: ./Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PUBLIC_RPC_URL=https://ghostnet.tezos.marigold.dev/
PUBLIC_API_URL=https://api.ghostnet.tzkt.io
PUBLIC_NETWORK_TYPE=ghostnet
# tagging
- name: Set tagging variables
if: ${{ github.ref != 'refs/heads/dev' }}
id: vars
run: |
echo "date=$(date +%Y-%m-%dT%H-%M-%S)" >> "${GITHUB_OUTPUT}"
echo "sha_short=$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}"
- name: Fetch tags
if: ${{ github.ref != 'refs/heads/dev' }}
run: |
git fetch --prune --unshallow
- name: Determine Tag Version
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/mainnet' }}
id: tag_version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.manual_tagging_version }}" ]]; then
NEW_TAG="${{ github.event.inputs.manual_tagging_version }}"
echo "Manual version override: $NEW_TAG"
else
# Determine new stable version
TAG=$(git tag -l | grep -v 'rc' | sort -V | tail -n1)
MAJOR=$(echo $TAG | sed -r 's/v([0-9]+)\.([0-9]+)\.([0-9]+)/\1/')
MINOR=$(echo $TAG | sed -r 's/v([0-9]+)\.([0-9]+)\.([0-9]+)/\2/')
if [ "$MINOR" -eq 99 ]; then
NEW_MAJOR=$((MAJOR + 1))
NEW_MINOR=0
else
NEW_MAJOR=$MAJOR
NEW_MINOR=$((MINOR + 1))
fi
NEW_TAG="v${NEW_MAJOR}.${NEW_MINOR}.0"
echo "Previous Tag: $TAG"
echo "Automatically calculated new version: $NEW_TAG"
fi
echo "new_version=$NEW_TAG" >> "${GITHUB_OUTPUT}"
echo "Tag that will be used: $NEW_TAG"
- name: Create Git tag
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/mainnet' }}
run: git tag ${{ steps.tag_version.outputs.new_version}} && git push origin ${{ steps.tag_version.outputs.new_version}}
# building and pushing docker images
- name: Build and push staging docker image
if: ${{ github.ref == 'refs/heads/ghostnet' }}
uses: docker/build-push-action@v4
with:
file: ./Dockerfile
push: true
tags: |
ghcr.io/marigold-dev/tzsafe:staging
ghcr.io/marigold-dev/tzsafe:${{ steps.vars.outputs.date }}-${{ steps.vars.outputs.sha_short }}-staging
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PUBLIC_RPC_URL=https://ghostnet.tezos.marigold.dev/
PUBLIC_API_URL=https://api.ghostnet.tzkt.io
PUBLIC_NETWORK_TYPE=ghostnet
- name: Build and push release docker image
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/mainnet' }}
uses: docker/build-push-action@v4
with:
file: ./Dockerfile
push: true
tags: |
ghcr.io/marigold-dev/tzsafe:stable
ghcr.io/marigold-dev/tzsafe:${{ steps.tag_version.outputs.new_version}}-release
ghcr.io/marigold-dev/tzsafe:${{ steps.vars.outputs.date }}-${{ steps.vars.outputs.sha_short }}-${{ steps.tag_version.outputs.new_version}}-release
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PUBLIC_RPC_URL=https://mainnet.tezos.marigold.dev/
PUBLIC_API_URL=https://api.tzkt.io
PUBLIC_NETWORK_TYPE=mainnet