Skip to content

Commit

Permalink
Merge pull request #358 from Concordium/deployment-workflow
Browse files Browse the repository at this point in the history
Added deployment workflows
  • Loading branch information
rasmus-kirk authored May 17, 2024
2 parents 184782a + 4b7ba95 commit c1e311f
Show file tree
Hide file tree
Showing 4 changed files with 308 additions and 19 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/deploy-ccd-js-gen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Deploy ccd-js-gen

on:
# Run automatically on tag push
push:
tags:
- ccd-js-gen/*
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "deploy-ccdjsgen"
cancel-in-progress: false

env:
NODE_VERSION: 18.16.0
RUST_VERSION: 1.62
RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn

- uses: Swatinem/rust-cache@v2
with:
workspaces: |
packages/rust-bindings
deps/concordium-base/rust-src
deps/concordium-base/concordium-contracts-common
- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v3
with:
path: |
./node_modules
./docs/node_modules
./packages/ccd-js-gen/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: Cache GRPC
id: cache-grpc
uses: actions/cache@v3
with:
path: |
./packages/sdk/src/grpc-api
key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }}
restore-keys: ${{ runner.os }}-grpc

- name: Get dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Build release
run: yarn build

- name: Store build-release
uses: actions/upload-artifact@v4
with:
name: build-release
path: |
packages/sdk/lib
packages/sdk/src
packages/ccd-js-gen/lib
packages/ccd-js-gen/src
packages/ccd-js-gen/bin
packages/rust-bindings/lib
packages/*/package.json
packages/*/README.md
upload-release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
environment: deploy-ccd-js-gen
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive

- name: Extract tag name
id: get_tag
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/ccd-js-gen/}"

- name: Test that tag version matches package.json version
run: test "${{ steps.get_tag.outputs.tag }}" = "$(jq -r ".version" packages/ccd-js-gen/package.json)" || exit 1

- name: Get build-output
uses: actions/download-artifact@v4
with:
path: packages
name: build-release

- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ccd-js-gen/v${{ steps.get_tag.outputs.tag_name }}
name: CCD-JS-Gen Release v${{ steps.get_tag.outputs.tag_name }}
artifacts: |
packages/*
draft: true

- name: Publish to NPM
run: npm publish --workspace packages/ccd-js-gen
env:
NODE_AUTH_TOKEN: '${{secrets.NPM_TOKEN}}'
127 changes: 127 additions & 0 deletions .github/workflows/deploy-rust-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Deploy rust-bindings

on:
# Run automatically on tag push
push:
tags:
- rust-bindings/*
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "deploy-rustbindings"
cancel-in-progress: false

env:
NODE_VERSION: 18.16.0
RUST_VERSION: 1.62
RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn

- uses: Swatinem/rust-cache@v2
with:
workspaces: |
packages/rust-bindings
deps/concordium-base/rust-src
deps/concordium-base/concordium-contracts-common
- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v3
with:
path: |
./node_modules
./docs/node_modules
./packages/ccd-js-gen/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: Cache GRPC
id: cache-grpc
uses: actions/cache@v3
with:
path: |
./packages/sdk/src/grpc-api
key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }}
restore-keys: ${{ runner.os }}-grpc

- name: Get dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Build release
run: yarn build

- name: Store build-release
uses: actions/upload-artifact@v4
with:
name: build-release
path: |
packages/sdk/lib
packages/sdk/src
packages/ccd-js-gen/lib
packages/ccd-js-gen/src
packages/ccd-js-gen/bin
packages/rust-bindings/lib
packages/*/package.json
packages/*/README.md
upload-release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
environment: deploy-rust-bindings
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive

- name: Extract tag name
id: get_tag
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/rust-bindings/}"

- name: Test that tag version matches package.json version
run: test "${{ steps.get_tag.outputs.tag }}" = "$(jq -r ".version" packages/rust-bindings/package.json)" || exit 1

- name: Get build-output
uses: actions/download-artifact@v4
with:
path: packages
name: build-release

- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: rust-bindings/v${{ steps.get_tag.outputs.tag_name }}
name: Rust-Bindings Release v${{ steps.get_tag.outputs.tag_name }}
artifacts: |
packages/*
draft: true

- name: Publish to NPM
run: npm publish --workspace packages/rust-bindings
env:
NODE_AUTH_TOKEN: '${{secrets.NPM_TOKEN}}'
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Deploy
name: Deploy SDK

on:
# Run automatically on tag push
push:
tags:
- sdk/*
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -13,7 +17,7 @@ permissions:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
group: "deploy-sdk"
cancel-in-progress: false

env:
Expand Down Expand Up @@ -119,7 +123,9 @@ jobs:
path: typedoc

deploy-typedoc:
needs: build-typedoc
needs:
- build-typedoc
- upload-release
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand All @@ -145,3 +151,42 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

upload-release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
environment: deploy-sdk
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive

- name: Extract tag name
id: get_tag
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/sdk/}"

- name: Test that tag version matches package.json version
run: test "${{ steps.get_tag.outputs.tag }}" = "$(jq -r ".version" packages/sdk/package.json)" || exit 1

- name: Get build-output
uses: actions/download-artifact@v4
with:
path: packages
name: build-release

- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: sdk/v${{ steps.get_tag.outputs.tag_name }}
name: SDK Release v${{ steps.get_tag.outputs.tag_name }}
artifacts: |
packages/*
draft: true

- name: Publish to NPM
run: npm publish --workspace packages/sdk
env:
NODE_AUTH_TOKEN: '${{secrets.NPM_TOKEN}}'
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@ each of the packages contained in this repository.
changes made.
- Commit and tag the release.
- Tag should be `sdk/x.y.z`.
- Run the deploy workflow.
- Under github actions, run the "deploy" workflow and download the
`build-release` artifact. Unpack this file and use it for the release.
- Publish the release to NPM.
- From the sdk package directory (packages/sdk) run `yarn npm publish`
- Push the tag
- Have another code owner accept the deployment

### rust-bindings

Expand All @@ -128,12 +125,8 @@ each of the packages contained in this repository.
- Add a change entry: Bumped @concordium/rust-bindings to x.y.z.
- Commit and tag the release.
- Tag should be `rust-bindings/x.y.z`.
- Build the release.
- Under github actions, run the "deploy" workflow and download the
`build-release` artifact. Unpack this file and use it for the release.
- Publish the release to NPM.
- From the rust-bindings package directory (packages/rust-bindings) run
`yarn npm publish`
- Push the tag
- Have another code owner accept the deployment

### ccd-js-gen

Expand All @@ -142,11 +135,8 @@ each of the packages contained in this repository.
the changes made.
- Commit and tag the release.
- Tag should be `ccd-js-gen/x.y.z`.
- Run the deploy workflow.
- Under github actions, run the "deploy" workflow and download the
`build-release` artifact. Unpack this file and use it for the release.
- Publish the release to NPM.
- From the ccd-js-gen package directory (packages/ccd-js-gen) run `yarn npm publish`
- Push the tag
- Have another code owner accept the deployment

## Test

Expand Down

0 comments on commit c1e311f

Please sign in to comment.