-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (156 loc) · 6.16 KB
/
dev-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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Development Release
on:
push:
branches:
- develop
tags-ignore:
- '*'
permissions:
contents: write
discussions: write
packages: write
jobs:
cleanup-old-releases:
name: Cleanup Old Development Releases
runs-on: ubuntu-22.04
steps:
- name: Delete old development releases
uses: dev-drprasad/delete-older-releases@v0.3.2
with:
keep_latest: 5
delete_tags: true
delete_tag_pattern: ^dev-
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-release:
name: Build and Create Development Release
needs: cleanup-old-releases
# Using a larger runner with more CPU cores and memory
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# Use all available cores for the build
- name: Build all workspace members
run: |
export CARGO_BUILD_JOBS=$(nproc)
cargo build --release --workspace
- name: Prepare binaries
run: |
mkdir -p release-artifacts
if [ -f target/release/miner ]; then
cp target/release/miner release-artifacts/miner-linux-x86_64
fi
if [ -f target/release/validator ]; then
cp target/release/validator release-artifacts/validator-linux-x86_64
fi
if [ -f target/release/orchestrator ]; then
cp target/release/orchestrator release-artifacts/orchestrator-linux-x86_64
fi
if [ -f target/release/discovery ]; then # Prepare discovery binary
cp target/release/discovery release-artifacts/discovery-linux-x86_64
fi
- name: Generate checksums
run: |
cd release-artifacts
for file in *-linux-x86_64; do
if [ -f "$file" ]; then
sha256sum "$file" | cut -d ' ' -f 1 > "${file}.checksum"
fi
done
cd ..
- name: Generate release tag
id: tag
run: |
echo "tag_name=dev-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.tag_name }}
name: Development Build ${{ steps.tag.outputs.tag_name }}
body: |
⚠️ Development Build (Not for Production Use)
Branch: develop
Commit: ${{ github.sha }}
Build Date: ${{ steps.tag.outputs.tag_name }}
Platform:
- Linux x86_64
Components:
- Miner
- Validator
- Orchestrator
- Discovery svc
Note: This is an automated development build. For stable releases, please use builds from the master branch.
files: release-artifacts/*
prerelease: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
# Setup Google Cloud SDK
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
# Upload to Google Cloud Storage
- name: Upload to GCS
run: |
gsutil -m cp -r release-artifacts/* gs://prime-miner/${{ steps.tag.outputs.tag_name }}/
gsutil -m cp -r gs://prime-miner/${{ steps.tag.outputs.tag_name }}/* gs://prime-miner/latest/
gsutil -m setmeta -h "Cache-Control:no-cache, max-age=0" gs://prime-miner/latest/**/*
- name: Generate Docker metadata
id: meta
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "repo_lower=${REPO_LOWER}" >> $GITHUB_OUTPUT
- name: Configure Docker for Artifact Registry
run: |
gcloud auth configure-docker us-east1-docker.pkg.dev
- 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.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Discovery image
uses: docker/build-push-action@v4
with:
context: .
file: ./discovery/Dockerfile
push: true
tags: |
ghcr.io/${{ steps.meta.outputs.repo_lower }}/discovery:dev
ghcr.io/${{ steps.meta.outputs.repo_lower }}/discovery:${{ steps.tag.outputs.tag_name }}
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/discovery:dev
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/discovery:${{ steps.tag.outputs.tag_name }}
- name: Build and push Validator image
uses: docker/build-push-action@v4
with:
context: .
file: ./validator/Dockerfile
push: true
tags: |
ghcr.io/${{ steps.meta.outputs.repo_lower }}/validator:dev
ghcr.io/${{ steps.meta.outputs.repo_lower }}/validator:${{ steps.tag.outputs.tag_name }}
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/validator:dev
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/validator:${{ steps.tag.outputs.tag_name }}
- name: Build and push Orchestrator image
uses: docker/build-push-action@v4
with:
context: .
file: ./orchestrator/Dockerfile
push: true
tags: |
ghcr.io/${{ steps.meta.outputs.repo_lower }}/orchestrator:dev
ghcr.io/${{ steps.meta.outputs.repo_lower }}/orchestrator:${{ steps.tag.outputs.tag_name }}
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/orchestrator:dev
us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/orchestrator:${{ steps.tag.outputs.tag_name }}