-
Notifications
You must be signed in to change notification settings - Fork 646
140 lines (121 loc) · 5.51 KB
/
neard_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
name: Neard binary and Docker image release
on:
# Run when a new release or rc is created
release:
types: [published]
push:
branches: master
workflow_dispatch:
inputs:
branch:
default: 'master'
description: "Nearcore branch to build and publish"
type: string
required: true
jobs:
binary-release:
name: "Build and publish neard binary"
runs-on: "ubuntu-20.04-16core"
environment: deploy
permissions:
id-token: write # required to use OIDC authentication
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::590184106962:role/GitHubActionsRunner
aws-region: us-west-1
- name: Checkout ${{ github.event.inputs.branch }} branch
if: ${{ github.event_name == 'workflow_dispatch'}}
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Checkout nearcore release
# for release events we need to checkout all branches to be able to determine
# later branch name
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name == 'release'}}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout repository for master branch
# In case of master branch we want to checkout with depth 1
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'release'}}
uses: actions/checkout@v4
- name: Neard binary build and upload to S3
run: ./scripts/binary_release.sh
- name: Update latest version metadata in S3
run: |
echo $(git rev-parse HEAD) > latest
BRANCH=$(git branch --show-current)
# in case of Release triggered run, branch is empty
if [ -z "$BRANCH" ]; then
BRANCH=$(git branch -r --contains=${{ github.ref_name }} | head -n1 | cut -c3- | cut -d / -f 2)
fi
aws s3 cp --acl public-read latest s3://build.nearprotocol.com/nearcore/$(uname)/${BRANCH}/latest
- name: Trigger packer image creation workflow
if: github.event_name != 'workflow_dispatch' && github.event_name == 'release'
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
COMMIT=$(git rev-parse HEAD)
BRANCH=$(git branch --show-current)
# in case of Release triggered run, branch is empty
if [ -z "$BRANCH" ]; then
BRANCH=$(git branch -r --contains=${{ github.ref_name }} | head -n1 | cut -c3- | cut -d / -f 2)
fi
curl -L -X POST -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAGODAPLATFORM_GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/PagodaPlatform/pkr-node/dispatches \
-d '{"event_type":"packer-build","client_payload":{"image-name":"near-node-${BRANCH}-${SHORT_SHA}","neard-binary-s3-uri":"s3://build.nearprotocol.com/nearcore/Linux/${BRANCH}/${COMMIT}/neard"}}'
- name: Trigger release metadata update workflow
if: github.event_name != 'workflow_dispatch' && github.event_name == 'release'
run: |
curl -L -X POST -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.NEARONE_GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/Near-One/infra-ops/dispatches \
-d '{"event_type":"metadata-update","client_payload":{"release":"${{ github.ref_name }}"}}'
docker-release:
name: "Build and publish nearcore Docker image"
runs-on: "ubuntu-20.04-16core"
environment: deploy
steps:
- name: Checkout ${{ github.event.inputs.branch }} branch
if: ${{ github.event_name == 'workflow_dispatch'}}
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Checkout nearcore release
# for release events we need to checkout all branches to be able to determine
# later branch name
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name == 'release'}}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout repository for master branch
# In case of master branch we want to checkout with depth 1
if: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'release'}}
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PAT_TOKEN }}
- name: Build and push Docker image to Dockerhub
run: |
COMMIT=$(git rev-parse HEAD)
BRANCH=$(git branch --show-current)
# in case of Release triggered run, branch is empty
if [ -z "$BRANCH" ]; then
BRANCH=$(git branch -r --contains=${{ github.ref_name }} | head -n1 | cut -c3- | cut -d / -f 2)
fi
make docker-nearcore
docker tag nearcore nearprotocol/nearcore:${BRANCH}-${COMMIT}
docker tag nearcore nearprotocol/nearcore:${BRANCH}
docker push nearprotocol/nearcore:${BRANCH}-${COMMIT}
docker push nearprotocol/nearcore:${BRANCH}
if [[ ${BRANCH} == "master" ]];
then
docker tag nearcore nearprotocol/nearcore:latest
docker push nearprotocol/nearcore:latest
fi