Skip to content

Commit

Permalink
Merge pull request #60 from okp4/ci/release
Browse files Browse the repository at this point in the history
🚀 Improve publish process
  • Loading branch information
bdeneux authored Sep 11, 2023
2 parents 30591d2 + a3cffdc commit d688047
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 378 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ jobs:
runs-on: ubuntu-22.04
needs: matrix
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
matrix:
proto: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -73,7 +74,7 @@ jobs:
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: 1.71
default: true
override: true

Expand All @@ -87,7 +88,7 @@ jobs:

- name: Generate proto
run: |
jq -c '.proto[]' proto.json | while read i; do
jq -c '.[]' 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')
Expand Down
69 changes: 14 additions & 55 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ jobs:
- id: set-matrix
run: echo "::set-output name=matrix::$(cat proto.json | jq -c .)"

publish-npm-okp4:
publish-npm-package:
runs-on: ubuntu-22.04
needs: matrix
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
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
Expand All @@ -44,75 +50,28 @@ jobs:
- name: Setup node environment (for publishing)
uses: actions/setup-node@v3
with:
node-version: 16.19.0
registry-url: "https://npm.pkg.github.com"
node-version: 18.12
registry-url: ${{ matrix.registry.url }}
scope: "@okp4"

- name: Publish package
run: |
set -eu
DATE=$(date +%Y%m%d%H%M%S)
yarn --cwd ${{ matrix.proto.directory.ts }} && yarn --cwd ${{ matrix.proto.directory.ts }} build
publish=(yarn --cwd ${{ matrix.proto.directory.ts }} publish --no-git-tag-version --non-interactive)
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)
elif [[ $GITHUB_EVENT_NAME == pull_request ]]; then
publish+=(--prerelease --preid ${{ env.CI_ACTION_REF_NAME_SLUG }}.$DATE --tag ${{ env.CI_ACTION_REF_NAME_SLUG }})
else
publish+=(--prerelease --preid next.$DATE --tag next)
fi
echo "🚀 Publishing npm package with following command line: ${publish[@]}"
"${publish[@]}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}

publish-npm-public:
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/github-env-vars-action@v2.7.0

- 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@v3
with:
node-version: 16.19.0
registry-url: "https://registry.npmjs.org"
scope: "@okp4"

- name: Publish package
run: |
set -eu
yarn --cwd ${{ matrix.proto.directory.ts }} && yarn --cwd ${{ matrix.proto.directory.ts }} build
publish=(yarn --cwd ${{ matrix.proto.directory.ts }} publish --access=public --no-git-tag-version --non-interactive --tag latest)
echo "🚀 Publishing npm package with following command line: ${publish[@]}"
"${publish[@]}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLIC_REGISTRY_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.auth-token-secret] }}

publish-crates:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
Expand All @@ -124,7 +83,7 @@ jobs:
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: 1.71
default: true
override: true

Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/release.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .releaserc.yml

This file was deleted.

6 changes: 3 additions & 3 deletions buf.gen.rust.cosmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ version: v1
managed:
enabled: true
plugins:
- remote: buf.build/prost/plugins/prost:v0.2.1-1
- plugin: buf.build/community/neoeinstein-prost:v0.2.1
out: src/gen
- remote: buf.build/prost/plugins/tonic:v0.2.1-1
- plugin: buf.build/community/neoeinstein-tonic:v0.2.2
out: src/gen
- remote: buf.build/prost/plugins/crate:v0.3.1-1
- plugin: buf.build/community/neoeinstein-prost-crate:v0.3.1
out: src/gen
opt:
- no_features
6 changes: 3 additions & 3 deletions buf.gen.rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ version: v1
managed:
enabled: true
plugins:
- remote: buf.build/prost/plugins/prost:v0.2.1-1
- plugin: buf.build/community/neoeinstein-prost:v0.2.1
out: src/gen
opt:
- extern_path=.cosmos=cosmos_sdk_grpc_client::cosmos
- remote: buf.build/prost/plugins/tonic:v0.2.1-1
- plugin: buf.build/community/neoeinstein-tonic:v0.2.2
out: src/gen
opt:
- extern_path=.cosmos=cosmos_sdk_grpc_client::cosmos
- remote: buf.build/prost/plugins/crate:v0.3.1-1
- plugin: buf.build/community/neoeinstein-prost-crate:v0.3.1
out: src/gen
opt:
- no_features
36 changes: 17 additions & 19 deletions proto.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"proto": [
{
"buf": "buf.build/okp4/okp4d",
"directory": {
"ts": "ts/okp4-grpc-client",
"rust": "rust/okp4-grpc-client",
"python": "python/okp4_grpc_client/okp4_grpc_client"
}
},
{
"buf": "buf.build/cosmos/cosmos-sdk:v0.47.0",
"directory": {
"ts": "ts/cosmos-sdk-grpc-client",
"rust": "rust/cosmos-sdk-grpc-client",
"python": "python/cosmos_sdk_grpc_client/cosmos_sdk_grpc_client"
}
[
{
"buf": "buf.build/okp4/okp4d",
"directory": {
"ts": "ts/okp4-grpc-client",
"rust": "rust/okp4-grpc-client",
"python": "python/okp4_grpc_client/okp4_grpc_client"
}
]
}
},
{
"buf": "buf.build/cosmos/cosmos-sdk:v0.47.0",
"directory": {
"ts": "ts/cosmos-sdk-grpc-client",
"rust": "rust/cosmos-sdk-grpc-client",
"python": "python/cosmos_sdk_grpc_client/cosmos_sdk_grpc_client"
}
}
]
Loading

0 comments on commit d688047

Please sign in to comment.