Skip to content

Commit

Permalink
feat: New release wf (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgusakov authored Jun 28, 2022
1 parent ade904f commit dd0375a
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 169 deletions.
117 changes: 0 additions & 117 deletions .github/dispatch_workflow.py

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/bump-version.yml

This file was deleted.

16 changes: 9 additions & 7 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ on:
branches:
- develop
paths-ignore:
- '.github/**'
- ".github/**"

jobs:
# test:
# ...

deploy:
runs-on: ubuntu-latest
# needs: test
name: Build and deploy
steps:
- name: Checkout
uses: actions/checkout@v2.3.5
uses: actions/checkout@v3

- name: Testnet deploying
run: .github/dispatch_workflow.py
- name: Testnet deploy
uses: lidofinance/dispatch-workflow@v1
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
TARGET_REPO: '${{ secrets.TARGET_REPO }}'
TARGET: 'develop'
TARGET_WORKFLOW: 'deploy_testnet_council_daemon.yaml'
TARGET_REPO: "lidofinance/infra-mainnet"
TARGET_WORKFLOW: "deploy_testnet_council_daemon.yaml"
40 changes: 27 additions & 13 deletions .github/workflows/ci-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,47 @@ name: CI Build prod image

on:
workflow_dispatch:
workflow_call:
inputs:
tag:
description: "tag to deploy from"
default: ""
required: false
type: string
push:
branches:
- '!*'
- "!*"
tags:
- '*'
- "*"
paths-ignore:
- '.github/**'
- ".github/**"

jobs:
# test:
# ...

deploy:
runs-on: ubuntu-latest
# needs: test
name: Build and deploy
steps:
- name: Checkout
uses: actions/checkout@v2.3.5

- name: Branch name
id: branch_name
uses: actions/checkout@v3
- name: Tag name
id: tag_name
run: |
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
if [ '${{ inputs.tag }}' = '' ]; then
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
else
echo ::set-output name=TAG::${{ inputs.tag }}
fi
- name: Build prod image
run: .github/dispatch_workflow.py
uses: lidofinance/dispatch-workflow@v1
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
TARGET_REPO: '${{ secrets.TARGET_REPO }}'
TAG: '${{ steps.branch_name.outputs.TAG }}'
TARGET_WORKFLOW: 'build_mainnet_council_daemon.yaml'
TARGET_REPO: "lidofinance/infra-mainnet"
TAG: "${{ steps.tag_name.outputs.TAG }}"
TARGET_WORKFLOW: "build_mainnet_council_daemon.yaml"
15 changes: 9 additions & 6 deletions .github/workflows/ci-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ on:
branches:
- main
paths-ignore:
- '.github/**'
- ".github/**"

jobs:
# test:
# ...

deploy:
runs-on: ubuntu-latest
# needs: test
name: Build and deploy
steps:
- name: Checkout
uses: actions/checkout@v2.3.5
uses: actions/checkout@v3

- name: Staging deploying
run: .github/dispatch_workflow.py
- name: Staging deploy
uses: lidofinance/dispatch-workflow@v1
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
TARGET_REPO: '${{ secrets.TARGET_REPO }}'
TARGET_WORKFLOW: 'deploy_staging_mainnet_council_daemon.yaml'
TARGET_REPO: "lidofinance/infra-mainnet"
TARGET_WORKFLOW: "deploy_staging_mainnet_council_daemon.yaml"
39 changes: 39 additions & 0 deletions .github/workflows/create-tag-and-trigger-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Create tag and trigger deploy
on:
push:
branches:
- main

jobs:
bump:
name: Create tag and release
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'chore(release)')"
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get tag value
id: tag
run: |
TAG=$(grep -oP '\d+\.\d+\.\d+' <<< '${{ github.event.head_commit.message }}')
echo $TAG
echo "::set-output name=tag::${TAG}"
- name: Create and push tag
run: |
git tag ${{ steps.tag.outputs.tag }}
git push origin --tags
- name: Create release
uses: lidofinance/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.tag }}

deploy-trigger:
needs: bump
name: Trigger build and PR creation in the infra-mainnet
if: "contains(github.event.head_commit.message, 'chore(release)')"
uses: ./.github/workflows/ci-prod.yml
secrets: inherit
with:
tag: ${{ needs.bump.outputs.tag}}
30 changes: 30 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Prepare release
on: workflow_dispatch

jobs:
prepare-release:
name: Prepare release and create pre-release PR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Bump version and update CHANGELOG.MD
id: changelog
uses: lidofinance/[email protected]
with:
git-message: "chore(release): {version}"
tag-prefix: ""
output-file: "CHANGELOG.md"
version-file: package.json
version-path: version
release-count: 10 # save all releases in the CHANGELOG.md
git-push: false
skip-on-empty: false

- name: Create Pull Request
uses: lidofinance/create-pull-request@v4
with:
branch: pre-release-${{ steps.changelog.outputs.version }}
title: "chore(release): ${{ steps.changelog.outputs.version }}"
body: "This PR is generated automatically.\nMerge it with **Rebase and merge** option or with the **Squash and merge** keeping default commit message (CRUCIAL) for the automatic tag creation.\nIf you don't need this PR than close it and **delete source branch**! "
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,15 @@ $ yarn test:e2e
# test coverage
$ yarn test:cov
```

## Release flow

To create new release:

1. Merge all changes to the `main` branch
1. Navigate to Repo => Actions
1. Run action "Prepare release" action against `main` branch
1. When action execution is finished, navigate to Repo => Pull requests
1. Find pull request named "chore(release): X.X.X" review and merge it with "Rebase and merge" (or "Squash and merge")
1. After merge release action will be triggered automatically
1. Navigate to Repo => Actions and see last actions logs for further details

0 comments on commit dd0375a

Please sign in to comment.