diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..454d36b5a --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/devtools/get_version.sh b/devtools/get_version.sh new file mode 100755 index 000000000..c8f1a4958 --- /dev/null +++ b/devtools/get_version.sh @@ -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" diff --git a/docs/release.md b/docs/release.md new file mode 100644 index 000000000..5b45724c1 --- /dev/null +++ b/docs/release.md @@ -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. \ No newline at end of file