Skip to content

Commit

Permalink
feat(templates/ci): add integration to auto release apps (#1239)
Browse files Browse the repository at this point in the history
* feat: add integration to auto release apps

through the Github CI.

* implemented a cli action under actions/cli.

* apps will be scaffold with a release workflow using the new starport
cli action and other 3rd party actions.

* added instructions about how to install an app through the curl+bash
installer.

* tweak

* docs

* Apply suggestions from code review

Co-authored-by: Denis Fadeev <[email protected]>

* fix

* Update starport/templates/app/stargate/readme.md.plush

Co-authored-by: Denis Fadeev <[email protected]>

* create/update "latest" release

everytime there is a change to the develop branch

* use default branch for "latest" release

* tweak

* tweak

* Update starport/templates/app/stargate/.github/workflows/release.yml

Co-authored-by: Denis Fadeev <[email protected]>

* Update starport/templates/app/stargate/readme.md.plush

Co-authored-by: Denis Fadeev <[email protected]>

* Apply suggestions from code review

Co-authored-by: Lucas Bertrand <[email protected]>

Co-authored-by: Denis Fadeev <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>
  • Loading branch information
3 people authored Jun 17, 2021
1 parent de13ae2 commit e55a8f5
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 67 deletions.
3 changes: 3 additions & 0 deletions actions/cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM starport/cli:develop

USER root
5 changes: 5 additions & 0 deletions actions/cli/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: cli
description: Starport CLI
runs:
using: docker
image: Dockerfile
22 changes: 22 additions & 0 deletions actions/cli/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Starport CLI Action
This action makes the `starport` CLI available as a Github Action.

## Quick start

Add a new workflow to your repo:

```yml
on: push

jobs:
help:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Print Help
uses: tendermint/starport/actions/cli@develop
with:
args: -h
```
50 changes: 50 additions & 0 deletions actions/release/vars/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: vars
description: Outputs variables that can be useful while creating a release
outputs:
should_release:
description: Indicates whether a release should be created or not
value: ${{ steps.vars.outputs.should_release }}
is_release_type_latest:
description: Shows if release type is latest (not a v* release)
value: ${{ steps.vars.outputs.is_release_type_latest }}
tag_name:
description: Name of the tag that should be used for release
value: ${{ steps.vars.outputs.tag_name }}
tarball_prefix:
description: A prefix to use in tarball asset names
value: ${{ steps.vars.outputs.tarball_prefix }}
runs:
using: "composite"
steps:
- id: vars
run: |
repo_name=${GITHUB_REPOSITORY##*/}
ref_name=${GITHUB_REF##*/}
default_branch=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
should_release=true
is_release_type_latest=false
tag_name=""
if [[ $GITHUB_REF == refs/tags/* ]]
then
tag_name=$ref_name
elif [[ $GITHUB_REF == refs/heads/* && $ref_name == $default_branch ]]
then
tag_name=latest
is_release_type_latest=true
else
should_release=false
fi
echo ::set-output name=should_release::$should_release
echo ::set-output name=is_release_type_latest::$is_release_type_latest
echo ::set-output name=tag_name::$tag_name
echo ::set-output name=tarball_prefix::"$repo_name"_$tag_name
shell: bash
- run: |
echo "- should_release: ${{ steps.vars.outputs.should_release }}"
echo "- is_release_type_latest: ${{ steps.vars.outputs.is_release_type_latest }}"
echo "- tag_name: ${{ steps.vars.outputs.tag_name }}"
echo "- tarball_prefix: ${{ steps.vars.outputs.tarball_prefix }}"
shell: bash
7 changes: 7 additions & 0 deletions starport/services/scaffolder/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/gobuffalo/genny"
"github.com/tendermint/starport/starport/pkg/giturl"
"github.com/tendermint/starport/starport/pkg/gomodulepath"
"github.com/tendermint/starport/starport/pkg/localfs"
"github.com/tendermint/starport/starport/pkg/placeholder"
Expand Down Expand Up @@ -62,11 +63,17 @@ func (s *Scaffolder) generate(
absRoot string,
noDefaultModule bool,
) error {
gu, err := giturl.Parse(pathInfo.RawPath)
if err != nil {
return err
}

g, err := app.New(&app.Options{
// generate application template
ModulePath: pathInfo.RawPath,
AppName: pathInfo.Package,
OwnerName: owner(pathInfo.RawPath),
OwnerAndRepoName: gu.UserAndRepo(),
BinaryNamePrefix: pathInfo.Root,
AddressPrefix: s.options.addressPrefix,
})
Expand Down
1 change: 1 addition & 0 deletions starport/templates/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func New(opts *Options) (*genny.Generator, error) {
ctx := plush.NewContext()
ctx.Set("ModulePath", opts.ModulePath)
ctx.Set("AppName", opts.AppName)
ctx.Set("OwnerAndRepoName", opts.OwnerAndRepoName)
ctx.Set("OwnerName", opts.OwnerName)
ctx.Set("BinaryNamePrefix", opts.BinaryNamePrefix)
ctx.Set("AddressPrefix", opts.AddressPrefix)
Expand Down
1 change: 1 addition & 0 deletions starport/templates/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package app
type Options struct {
AppName string
OwnerName string
OwnerAndRepoName string
BinaryNamePrefix string
ModulePath string
AddressPrefix string
Expand Down
39 changes: 0 additions & 39 deletions starport/templates/app/stargate/.github/workflows/build.yml.plush

This file was deleted.

24 changes: 0 additions & 24 deletions starport/templates/app/stargate/.github/workflows/pages.yml

This file was deleted.

51 changes: 51 additions & 0 deletions starport/templates/app/stargate/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow is useful if you want to automate the process of:
#
# a) Creating a new prelease when you push a new tag with a "v" prefix (version).
#
# This type of prerelease is meant to be used for production: alpha, beta, rc, etc. types of releases.
# After the prerelease is created, you need to make your changes on the release page at the relevant
# Github page and publish your release.
#
# b) Creating/updating the "latest" prerelease when you push to your default branch.
#
# This type of prelease is useful to make your bleeding-edge binaries available to advanced users.
#
# The workflow will not run if there is no tag pushed with a "v" prefix and no change pushed to your
# default branch.
on: push

jobs:
might_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare Release Variables
id: vars
uses: tendermint/starport/actions/release/vars@develop

- name: Issue Release Assets
uses: tendermint/starport/actions/cli@develop
if: ${{ steps.vars.outputs.should_release == 'true' }}
with:
args: build --release --release.prefix ${{ steps.vars.outputs.tarball_prefix }} -t linux:amd64 -t linux:arm64 -t darwin:amd64 -t darwin:arm64

- name: Delete the "latest" Release
uses: dev-drprasad/[email protected]
if: ${{ steps.vars.outputs.is_release_type_latest == 'true' }}
with:
tag_name: ${{ steps.vars.outputs.tag_name }}
delete_release: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish the Release
uses: softprops/action-gh-release@v1
if: ${{ steps.vars.outputs.should_release == 'true' }}
with:
tag_name: ${{ steps.vars.outputs.tag_name }}
files: release/*
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 21 additions & 4 deletions starport/templates/app/stargate/readme.md.plush
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# <%= AppName %>

**<%= AppName %>** is a blockchain built using Cosmos SDK and Tendermint and created with [Starport](https://github.com/tendermint/starport).

## Get started
Expand All @@ -10,15 +9,15 @@ starport serve

`serve` command installs dependencies, builds, initializes, and starts your blockchain in development.

## Configure
### Configure

Your blockchain in development can be configured with `config.yml`. To learn more, see the [Starport docs](https://docs.starport.network).

## Launch
### Launch

To launch your blockchain live on multiple nodes, use `starport network` commands. Learn more about [Starport Network](https://github.com/tendermint/spn).

## Web Frontend
### Web Frontend

Starport has scaffolded a Vue.js-based web app in the `vue` directory. Run the following commands to install dependencies and start the app:

Expand All @@ -30,6 +29,24 @@ npm run serve

The frontend app is built using the `@starport/vue` and `@starport/vuex` packages. For details, see the [monorepo for Starport front-end development](https://github.com/tendermint/vue).

## Release
To release a new version of your blockchain, create and push a new tag with `v` prefix. A new draft release with the configured targets will be created.

```
git tag v0.1
git push origin v0.1
```

After a draft release is created, make your final changes from the release page and publish it.

### Install
To install the latest version of your blockchain node's binary, execute the following command on your machine:

```
curl https://get.starport.network/<%= OwnerAndRepoName %>@latest! | sudo bash
```
`<%= OwnerAndRepoName %>` should match the `username` and `repo_name` of the Github repository to which the source code was pushed. Learn more about [the install process](https://github.com/allinbits/starport-installer).

## Learn more

- [Starport](https://github.com/tendermint/starport)
Expand Down

0 comments on commit e55a8f5

Please sign in to comment.