Skip to content

Commit

Permalink
feat: Add release automation config (#108)
Browse files Browse the repository at this point in the history
* feat: Add release automation config

* fix: remove unneeded cmd

* feat: add doc for release

* fix: apply review

* ci: fix release process

* chore: fix generate_release_tag

* fix: remove template and fix release.yml

* chore: edit docs

* fix: change flow

* fix: fix error

* chore: fix grep format

* fix: remove libgcc

* fix: add check version
  • Loading branch information
shiki-tak authored Sep 7, 2021
1 parent 92ea5ec commit 11bd9d8
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on:
pull_request:
branches:
- main
types: [closed]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
release:
runs-on: ubuntu-latest
container: cibuilds/github:0.13
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install libgcc
run: apk add libgcc
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.51.0
target: wasm32-unknown-unknown
profile: minimal
override: true
- name: Get version
id: get_version
run: |
VERSION=$(./devtools/get_version.sh)
echo ::set-output name=version::$VERSION
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
- name: Check version
id: tag_check
uses: dudo/tag_check@v1.1.1
with:
version: ${{ steps.get_version.outputs.version }}
git_tag_prefix: v

- name: Create new tag
run: |
if [ -z "${{ steps.get_version.outputs.version }}" ]; then
git tag ${{ steps.get_version.outputs.version }}
fi
- name: Install Docker client
run: |
apk add docker-cli
- name: Prepare volume with source code
run: |
# create a dummy container which will hold a volume with config
docker create -v /code --name with_code alpine /bin/true
# copy a config file into this volume
docker cp ./Cargo.toml with_code:/code
docker cp ./contracts with_code:/code
docker cp ./packages with_code:/code
- name: Build development contracts
run: |
echo "Building all contracts under ./contracts"
docker run --volumes-from with_code cosmwasm/rust-optimizer:0.11.0 ./contracts/*/
- name: Check development contracts
working-directory: ./
run: |
echo "Checking all contracts under ./artifacts"
docker run --volumes-from with_code rust:1.51.0 /bin/bash -e -c 'cd ./code/packages/vm; ./examples/check_contract.sh ../../artifacts/*.wasm'
docker cp with_code:/code/artifacts .
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
body: ${{ github.event.pull_request.body }}
files: |
./artifacts/*
draft: false
prerelease: false
13 changes: 13 additions & 0 deletions devtools/get_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
packages=("cosmwasm-derive" "cosmwasm-schema" "cosmwasm-std" "cosmwasm-storage" "cosmwasm-vm")

V=$(cargo tree -i "cosmwasm-crypto" | grep -o -E "\d+(\.\d+){2}-\d+(\.\d+){2}" | head -n1)

for ((i = 0; i < ${#packages[@]}; i++)) {
if [ "$V" != $(cargo tree -i "${packages[i]}" | grep -o -E "\d+(\.\d+){2}-\d+(\.\d+){2}" | head -n1) ]; then
echo "mismatch version"
exit 1
fi
}

echo "$V"
23 changes: 23 additions & 0 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# How to release.
- Please refer to the following file for the config file for release.
1. .github/changelog.yml
- Update CHANGELOG when issuing a PR for release.
2. .github/release.yml
- Executed when PR is merged into main.

### What we can do with this.
1. Automatically create a new version from the branch name.
2. Upload dev contracts
3. Publish

### Release process
1. Update the version using the script (`devtools/set_version.sh`).
2. Update the changelog using the script (`devtools/update_changelog.sh`).
- the script generates and appends new logs to `CHANGELOG.md` using [git-chglog](https://github.com/git-chglog/git-chglog).
3. Review the changelogs generated by scripts.
4. Make a release PR with a proper target branch.
- The PR comment becomes the body of the release note.
5. Do PR review and merge.
6. After merging it, CI will detect version changes.
- __comparing with a previously released version using cargo command (`cargo tree -i cosmwasm-xxx`)__
7. CI will create a new version tag and publish artifacts with release notes.

0 comments on commit 11bd9d8

Please sign in to comment.