forked from moonbeam-foundation/moonbeam
-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (144 loc) · 5.19 KB
/
publish-binary.yml
File metadata and controls
154 lines (144 loc) · 5.19 KB
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
name: Publish Binary Draft
# The code (like generate-release-body) will be taken from the tag version, not master
on:
workflow_dispatch:
inputs:
from:
description: tag (ex. v0.43.0) to retrieve commit diff from
required: true
to:
description: tag (ex. v0.44.0) to generate release note and binaries from
required: true
jobs:
build-binary:
runs-on: moonbeam-release-medium
permissions:
contents: read
strategy:
matrix:
cpu: ["x86-64", "skylake", "znver3"]
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.to }}
fetch-depth: 0
- name: Cargo build
uses: ./.github/workflow-templates/build-prod-binary
with:
target: ${{ matrix.cpu }}
ref: ${{ github.event.inputs.to }}
####### Prepare the release draft #######
publish-draft-release:
runs-on: ubuntu-latest
permissions:
contents: write
needs: ["build-binary"]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.to }}
fetch-depth: 0
- uses: actions/download-artifact@v5
with:
pattern: binaries-*
merge-multiple: true
path: build
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: "test/.nvmrc"
- name: Generate release body
id: generate-release-body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: tools
run: |
mv ../build/moonbeam-x86-64 ../build/moonbeam
yarn
yarn -s run ts-node github/generate-release-body.ts --owner "${{ github.repository_owner }}" --repo "$(basename ${{ github.repository }})" --from "${{ github.event.inputs.from }}" --to "${{ github.event.inputs.to }}" --srtool-report-folder '../build/' > ../body.md
- name: Create draft release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.to }}
release_name: Moonbeam ${{ github.event.inputs.to }}
body_path: body.md
draft: true
####### Upload Binaries #######
upload-binaries:
runs-on: ubuntu-latest
needs: ["build-binary", "publish-draft-release"]
strategy:
matrix:
cpu: ["x86-64", "skylake", "znver3"]
node: ["moonbeam"]
steps:
- uses: actions/download-artifact@v5
with:
pattern: binaries-*
merge-multiple: true
path: build
- name: Upload moonbeam
uses: actions/upload-release-asset@v1
if: ${{ matrix.cpu == 'x86-64' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
asset_path: build/${{matrix.node}}-${{matrix.cpu}}
asset_name: ${{matrix.node}}
asset_content_type: application/octet-stream
- name: Upload moonbeam custom binary
uses: actions/upload-release-asset@v1
if: ${{ matrix.cpu != 'x86-64' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
asset_path: build/${{matrix.node}}-${{matrix.cpu}}
asset_name: ${{matrix.node}}-${{matrix.cpu}}
asset_content_type: application/octet-stream
####### Publish Release Candidate Docker Image #######
docker-release-candidate:
runs-on: ubuntu-latest
needs: ["build-binary", "publish-draft-release"]
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.to }}
- uses: actions/download-artifact@v5
with:
pattern: binaries-*
merge-multiple: true
path: build
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=moonbeamfoundation/moonbeam
VERSION="${{ github.event.inputs.to }}"
TAG="${VERSION}-rc"
# Rename binary
mv build/moonbeam-x86-64 build/moonbeam
echo "tags=${DOCKER_IMAGE}:${TAG}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Cargo build
uses: ./.github/workflow-templates/publish-docker
with:
dockerhub_username: ${{ secrets.MBF_DOCKERHUB_USERNAME }}
dockerhub_password: ${{ secrets.MBF_DOCKERHUB_PASSWORD }}
image_tags: ${{ steps.prep.outputs.tags }}
image_title: ${{ github.event.repository.name }}
image_description: ${{ github.event.repository.description }}
image_url: ${{ github.event.repository.html_url }}
image_source: ${{ github.event.repository.clone_url }}
image_created: ${{ steps.prep.outputs.created }}
image_revision: ${{ github.sha }}
image_licenses: ${{ github.event.repository.license.spdx_id }}