generated from okp4/template-oss
-
Notifications
You must be signed in to change notification settings - Fork 1
152 lines (126 loc) · 4.49 KB
/
publish.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
name: Publish
on:
push:
branches: [main]
tags: ["v*"]
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true
jobs:
matrix:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: set-matrix
run: echo "::set-output name=matrix::$(cat proto.json | jq -c .)"
publish-npm-package:
runs-on: ubuntu-22.04
needs: matrix
strategy:
matrix:
registry:
- url: "https://npm.pkg.github.com"
auth-token-secret: NPM_REGISTRY_TOKEN
- url: "https://registry.npmjs.org"
auth-token-secret: NPM_PUBLIC_REGISTRY_TOKEN
proto: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up context
id: project_context
uses: FranzDiebold/[email protected]
- name: Configure buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Generate proto
run: |
buf generate --template buf.gen.ts.yaml ${{ matrix.proto.buf }} -o ${{ matrix.proto.directory.ts }}
- name: Setup node environment (for publishing)
uses: actions/setup-node@v4
with:
node-version: 18.12
registry-url: ${{ matrix.registry.url }}
scope: "@okp4"
- name: Publish package
run: |
set -eu
yarn --cwd ${{ matrix.proto.directory.ts }} && yarn --cwd ${{ matrix.proto.directory.ts }} build
DATE=$(date +%Y%m%d%H%M%S)
publish=(yarn --cwd ${{ matrix.proto.directory.ts }} publish --access=public --no-git-tag-version --non-interactive)
if [[ $GITHUB_REF == refs/tags/v* ]]; then
publish+=(--tag latest)
else
publish+=(--prerelease --preid next.$DATE --tag next)
fi
echo "🚀 Publishing npm package with following command line: ${publish[@]}"
"${publish[@]}"
env:
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.auth-token-secret] }}
publish-crates:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.71
default: true
override: true
- name: Install cargo make
uses: davidB/rust-cargo-make@v1
- name: Configure buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Generate proto
run: |
jq -c '.proto[]' proto.json | while read i; do
BUF=$(echo $i | jq -cr '.buf')
BUF_YAML=$(grep -q "cosmos/cosmos-sdk" <<< "$BUF" && echo "buf.gen.rust.cosmos.yaml" || echo "buf.gen.rust.yaml")
DIRECTORY=$(echo $i | jq -cr '.directory.rust')
buf generate --template $BUF_YAML $BUF -o $DIRECTORY
done
- name: Publish packages
working-directory: ./rust
run: |
echo "🚀 Publishing cargo package"
cargo make --env CARGO_API_TOKEN="${{ secrets.CARGO_API_TOKEN }}" -- publish
publish-pypi:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
needs: matrix
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up context
id: project_context
uses: FranzDiebold/[email protected]
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Python Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.4.1
- name: Configure buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Generate proto
run: |
buf generate --template buf.gen.python.yaml ${{ matrix.proto.buf }} -o ${{ matrix.proto.directory.python }}
- name: Publish package
working-directory: ./${{ matrix.proto.directory.python }}/../
run: |
poetry install
poetry build
echo "🚀 Publishing pypi package '${{ matrix.proto.directory.python }}'"
poetry publish -u __token__ -p "${{ secrets.PYPI_API_TOKEN }}"