-
Notifications
You must be signed in to change notification settings - Fork 115
166 lines (146 loc) · 5.6 KB
/
protocol-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
name: Release
# This workflow helps with creating releases.
# This job will only be triggered when a protocol release tag is pushed
on: # yamllint disable-line rule:truthy
push:
# Sequence of patterns matched against refs/tags
tags:
- "protocol/v[0-9]+.[0-9]+.[0-9]+" # e.g.: protocol/v1.0.1
- "protocol/v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" # e.g.: protocol/v1.0.1-rc1
- "protocol/v[0-9]+.[0-9]+.[0-9]+-dev[0-9]+" # e.g.: protocol/v1.0.1-dev1
jobs:
protocol-release:
name: Create Release
permissions:
contents: write
defaults:
run:
working-directory: ./protocol
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: set tag env
run: echo "VERSION=${GITHUB_REF#refs/tags/protocol/}" >> $GITHUB_ENV
- name: install go
uses: actions/setup-go@v3
with:
go-version: '1.22'
check-latest: true
- name: Create Directory
run: mkdir ./build
- name: Build Reproducible Linux Binaries
run: make distclean build-reproducible
- name: Rename Binaries
run: |
mv ./build/dydxprotocold:linux-arm64 ./build/dydxprotocold-${{ env.VERSION }}-linux-arm64
mv ./build/dydxprotocold:linux-amd64 ./build/dydxprotocold-${{ env.VERSION }}-linux-amd64
- name: Compress binaries
run: |
tar -cvzf dydxprotocold-${{ env.VERSION }}-linux-arm64.tar.gz \
./build/dydxprotocold-${{ env.VERSION }}-linux-arm64
tar -cvzf dydxprotocold-${{ env.VERSION }}-linux-amd64.tar.gz \
./build/dydxprotocold-${{ env.VERSION }}-linux-amd64
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
# TODO(DEC-1743): add more helpful release notes and change logs
body: Release ${{ env.VERSION }}
draft: true
prerelease: false
- name: Upload linux-amd64 tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: protocol/dydxprotocold-${{ env.VERSION }}-linux-amd64.tar.gz
asset_name: dydxprotocold-${{ env.VERSION }}-linux-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload linux-arm64 tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: protocol/dydxprotocold-${{ env.VERSION }}-linux-arm64.tar.gz
asset_name: dydxprotocold-${{ env.VERSION }}-linux-arm64.tar.gz
asset_content_type: application/gzip
# TODO(DEC-1743): add build report and binary check sums
v4-proto-py-release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./v4-proto-py
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install buf
run: |
BIN="/usr/local/bin" && \
VERSION="1.26.1" && \
curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-Linux-x86_64" -o "${BIN}/buf" && \
chmod +x "${BIN}/buf"
- name: Install Requirements
run: pip install -r requirements-publish.txt
- name: Generate v4-proto-py
working-directory: ./ # Move to parent folder
run: make v4-proto-py-gen
- name: Set Env from Tag (remove 'v' prefix)
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/protocol/v} | tr '-' '.')" >> $GITHUB_ENV
- name: Update version in setup.py
run: echo $VERSION; sed -i "s/0.0.0/$VERSION/g" setup.py
- name: Build package and source tarball
run: |
pip3 wheel --no-deps -w dist .
python3 setup.py sdist -d dist
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload -r pypi dist/*
v4-proto-js-release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./v4-proto-js
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Npm
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
cache: "npm"
cache-dependency-path: '**/package-lock.json'
- name: Install buf
run: |
BIN="/usr/local/bin" && \
VERSION="1.26.1" && \
curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-Linux-x86_64" -o "${BIN}/buf" && \
chmod +x "${BIN}/buf"
- name: Set Env from Tag to follow semver
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/protocol/v} | sed -r 's/(.*-[[:alpha:]]+)([[:digit:]]+)/\1.\2/')" >> $GITHUB_ENV
- name: Update version in package.json
run: echo $VERSION; sed -i "s/0.0.0/$VERSION/g" package.json
- name: Install
run: npm i
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_READ }}
- name: Transpile
run: npm run transpile
- name: Publish
run: ./scripts/publish-if-not-exists.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_WRITE }}