Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add release automation config #108

Merged
merged 14 commits into from
Sep 7, 2021
19 changes: 19 additions & 0 deletions .chglog/CHANGELOG-LINK.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CHANGELOG LINK
This is CHANGELOG after this repository was forked from CosmWasm/cosmwasm.
{{ range .Versions }}
## {{ if .Tag.Previous }}{{ .Tag.Name }}{{ else }}{{ .Tag.Name }}{{ end }}
whylee259 marked this conversation as resolved.
Show resolved Hide resolved
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
27 changes: 27 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
style: github
template: CHANGELOG-LINK.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/line/cosmwasm
options:
whylee259 marked this conversation as resolved.
Show resolved Hide resolved
commits:
filters:
Type:
- feat
- fix
- perf
- refactor
commit_groups:
title_maps:
feat: Features
fix: Fixes
perf: Performance Improvements
refactor: Code Refactoring
header:
pattern: "^(\\w*)\\:\\s(.*)$"
pattern_maps:
- Type
- Subject
whylee259 marked this conversation as resolved.
Show resolved Hide resolved
notes:
keywords:
- BREAKING CHANGE
35 changes: 35 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: changelog

on:
pull_request:
whylee259 marked this conversation as resolved.
Show resolved Hide resolved

jobs:
changelog:
name: Generate Changelog
if: startsWith(github.event.pull_request.head.ref, 'release-v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get version
id: get_version
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: echo ::set-output name=VERSION::${HEAD_REF#release-v}
- name: Create new tag
run: |
git tag v${{ steps.get_version.outputs.VERSION }}
whylee259 marked this conversation as resolved.
Show resolved Hide resolved

- name: Update CHANGELOG-LINK.md
working-directory: ./
run: |
docker pull quay.io/git-chglog/git-chglog:latest
docker run -v "$PWD":/workdir quay.io/git-chglog/git-chglog -o CHANGELOG-LINK.md v0.12.0-0.1.0..
loloicci marked this conversation as resolved.
Show resolved Hide resolved
whylee259 marked this conversation as resolved.
Show resolved Hide resolved
- name: Merge CHANGELOG-LINK.md
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: Update CHANGELOG-LINK.md"
whylee259 marked this conversation as resolved.
Show resolved Hide resolved
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release

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

jobs:
release:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release-v')
whylee259 marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
container: cibuilds/github:0.13
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${HEAD_REF#release-v}
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
- name: Install Docker client
run: |
apk add docker-cli
- name: Checkout
uses: actions/checkout@v2
- 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/*/
whylee259 marked this conversation as resolved.
Show resolved Hide resolved
- 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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.VERSION }}
body: ${{ github.event.pull_request.body }}
files: |
./artifacts/*
draft: false
prerelease: false
26 changes: 26 additions & 0 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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. Automatically generate and commit a changelog.
3. Upload dev contracts
4. Publish

### Release process
1. Update the version of Cargo.toml.
2. Make PR to main branch
- The format of the branch name should be release-vx.x.x-x.x.x.
- PR's comment becomes the body of the release notes.
3. On the PR, CI job(changelog.yml) extracts target version from branch name.
4. CI job create new tag from branch name.
5. CI job generates the changelog and appends to CHANGELOG-LINK.md
- using [git-chglog](https://github.com/git-chglog/git-chglog)
6. Github Actions automatically commit CHANGELOG-LINK.md.
7. PR review.
8. merge -> main
9. On the main, CI job(release.yml) publish artifacts and create release notes.