Skip to content

Commit

Permalink
feat(release): implement release with image build
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Oct 14, 2024
1 parent c0d50b1 commit a9fa7e8
Show file tree
Hide file tree
Showing 50 changed files with 3,869 additions and 138 deletions.
3 changes: 2 additions & 1 deletion .commitlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"certificate",
"dx",
"config",
"stats"
"stats",
"release"
]
]
}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/docker-build-deploy-web.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Deploy Web CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

Expand All @@ -24,4 +22,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.deploy-web == 'true'
run: npm run dc:build -- --build-arg DEPLOYMENT_ENV=production deploy-web
run: packages/docker/script/dc.sh build deploy-web --build-arg DEPLOYMENT_ENV=production
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.indexer == 'true'
run: npm run dc:build -- indexer
run: packages/docker/script/dc.sh build indexer
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-provider-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.provider-proxy == 'true'
run: npm run dc:build -- provider-proxy
run: packages/docker/script/dc.sh build provider-proxy
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-stats-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.stats-web == 'true'
run: npm run dc:build -- --build-arg DEPLOYMENT_ENV=production stats-web
run: packages/docker/script/dc.sh build stats-web --build-arg DEPLOYMENT_ENV=production
54 changes: 54 additions & 0 deletions .github/workflows/release-all-apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release All Apps

on:
push:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.14.0

- name: Restore root node_modules cache
uses: martijnhols/actions-cache@v3
id: cache
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the Docker images
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Akash Network Team"
npm run release -w apps/api -- --preRelease=beta --verbose --ci -r ${{ vars.API_REGISTRY }}
npm run release -w apps/deploy-web -- --preRelease=beta -f --verbose --ci -r ${{ vars.WEB_REGISTRY }}
84 changes: 84 additions & 0 deletions .github/workflows/release-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Release App

on:
workflow_dispatch:
inputs:
app:
type: choice
description: Which app to release
options:
- api
- deploy-web
required: true
release-type:
type: choice
description: Which app to release
options:
- prod
- beta
default: prod
force-build:
type: boolean
description: Rebuild the Docker image
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.14.0

- name: Restore root node_modules cache
uses: martijnhols/actions-cache@v3
id: cache
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the Docker images
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Akash Network Team"
pre_release=""
if [[ "${{ github.event.inputs.release-type }}" == 'beta' ]]; then
prerelease="--preRelease=beta"
fi
force_build=""
if [[ "${{ github.event.inputs.force-build }}" == 'true' ]]; then
force_build="-f"
fi
repo="${{ github.event.inputs.app == 'api' && vars.API_REGISTRY || vars.WEB_REGISTRY }}"
npm run release -w apps/${{ github.event.inputs.app }} -- $pre_release $force_build --verbose --ci -r $repo
4 changes: 1 addition & 3 deletions .github/workflows/validate-n-build-api.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Validate and Build API

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

Expand Down Expand Up @@ -55,4 +53,4 @@ jobs:

- name: Build the Docker image for API
if: steps.filter.outputs.api == 'true'
run: npm run dc:build -- api
run: packages/docker/script/dc.sh build api
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if [[ "$CI" != "true" ]]; then
turbo update-apps-local-deps \
--filter=./packages/database \
--filter=./packages/env-loader \
--filter=./packages/http-sdk \
--filter=./packages/ui
git add ./apps/*/mvm.lock
fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Running the Application](#running-the-application)
- [Manual Database Restoration](#manual-database-restoration)
- [Database Structure](./doc/database-structure.md)
- [Release Workflow](./doc/release-workflow.md)
- [Contributing](#contributing)
- [License](#license)

Expand Down
1 change: 1 addition & 0 deletions apps/api/.release-it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@akashnetwork/releaser")
10 changes: 10 additions & 0 deletions apps/api/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
"@akashnetwork/database": "1.0.0",
"@akashnetwork/env-loader": "1.0.1",
"@akashnetwork/http-sdk": "1.0.7"
},
"devDependencies": {
"@akashnetwork/dev-config": "1.0.0"
}
}
Empty file removed apps/api/package-lock.json
Empty file.
9 changes: 7 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "console-api",
"name": "@akashnetwork/console-api",
"version": "2.23.4",
"description": "Api providing data to the deploy tool",
"repository": {
Expand Down Expand Up @@ -29,7 +29,8 @@
"test:unit": "jest --selectProjects unit",
"test:unit:cov": "jest --selectProjects unit --coverage",
"test:unit:watch": "jest --selectProjects unit --watch",
"test:watch": "jest --selectProjects unit functional --watch"
"test:watch": "jest --selectProjects unit functional --watch",
"release": "release-it"
},
"dependencies": {
"@akashnetwork/akash-api": "^1.3.0",
Expand Down Expand Up @@ -97,7 +98,10 @@
},
"devDependencies": {
"@akashnetwork/dev-config": "*",
"@akashnetwork/docker": "*",
"@akashnetwork/releaser": "*",
"@faker-js/faker": "^8.4.1",
"@release-it/conventional-changelog": "github:akash-network/conventional-changelog#feature/pre-release",
"@types/http-assert": "^1.5.5",
"@types/http-errors": "^2.0.4",
"@types/jest": "^29.5.12",
Expand All @@ -121,6 +125,7 @@
"nodemon-webpack-plugin": "^4.8.2",
"prettier": "^3.3.0",
"prettier-plugin-tailwindcss": "^0.6.1",
"release-it": "^17.6.0",
"supertest": "^6.1.5",
"ts-jest": "^29.1.4",
"ts-loader": "^9.2.5",
Expand Down
1 change: 1 addition & 0 deletions apps/deploy-web/.release-it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@akashnetwork/releaser")
10 changes: 10 additions & 0 deletions apps/deploy-web/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
"@akashnetwork/env-loader": "1.0.1",
"@akashnetwork/http-sdk": "1.0.7",
"@akashnetwork/ui": "1.0.0"
},
"devDependencies": {
"@akashnetwork/dev-config": "1.0.0"
}
}
7 changes: 5 additions & 2 deletions apps/deploy-web/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "akash-console",
"name": "@akashnetwork/console-web",
"version": "2.16.2",
"private": true,
"description": "Web UI to deploy on the Akash Network and view statistic about network usage.",
Expand All @@ -12,7 +12,8 @@
"format": "prettier --write ./*.{ts,js,json} **/*.{ts,tsx,js,json}",
"lint": "eslint .",
"start": "next start",
"type-check": "tsc"
"type-check": "tsc",
"release": "release-it"
},
"dependencies": {
"@akashnetwork/akash-api": "^1.3.0",
Expand Down Expand Up @@ -115,6 +116,7 @@
"@keplr-wallet/types": "^0.12.111",
"@next/bundle-analyzer": "^14.0.1",
"@playwright/test": "^1.45.0",
"@release-it/conventional-changelog": "github:akash-network/conventional-changelog#feature/pre-release",
"@types/auth0": "^2.35.3",
"@types/file-saver": "^2.0.5",
"@types/js-yaml": "^4.0.5",
Expand All @@ -134,6 +136,7 @@
"postcss-nesting": "^12.0.2",
"prettier": "^3.3.0",
"prettier-plugin-tailwindcss": "^0.6.1",
"release-it": "^17.6.0",
"tailwindcss": "^3.4.3",
"typescript": "5.1.3"
},
Expand Down
9 changes: 9 additions & 0 deletions apps/indexer/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dependencies": {
"@akashnetwork/database": "1.0.0",
"@akashnetwork/env-loader": "1.0.1"
},
"devDependencies": {
"@akashnetwork/dev-config": "1.0.0"
}
}
8 changes: 8 additions & 0 deletions apps/provider-console/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"@akashnetwork/ui": "1.0.0"
},
"devDependencies": {
"@akashnetwork/dev-config": "1.0.0"
}
}
5 changes: 5 additions & 0 deletions apps/provider-proxy/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"@akashnetwork/dev-config": "1.0.0"
}
}
8 changes: 8 additions & 0 deletions apps/stats-web/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"@akashnetwork/ui": "1.0.0"
},
"devDependencies": {
"@akashnetwork/dev-config": "1.0.0"
}
}
51 changes: 51 additions & 0 deletions doc/release-workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Release Workflow Documentation

## Overview

This release workflow leverages **release-it**, **Docker**, **Docker Compose**, **GitHub Actions**, and a set of custom CLI bash scripts to manage the release process. The workflow adheres to **Semantic Versioning (SemVer)** and supports both beta pre-releases and final releases.

## Release Flow

The release process is divided into two key stages: pre-release (beta) and final release. This is done using SemVer conventions.

### 1. Pre-Release (Beta)

To create a **pre-release** (beta) version, the following command is used. This will create a beta version using the `release-it` tool with the specified options:

```bash
npm run release -w apps/$APP -- --preRelease=beta --verbose --ci -r $REGISTRY
```

#### Key Options:
- `--preRelease`: Marks the release as a beta pre-release.
- `--verbose`: Provides detailed output for troubleshooting.
- `--ci`: Ensures the release runs in a continuous integration environment.
- `-r`: Registry to push the Docker image.

### 2. Final Release

For creating a final release, the command below is used. This will bump the version based on SemVer and push the release.

```bash
npm run release -w apps/$APP -- --verbose --ci -r $REGISTRY
```

This should be run manually after validating the beta pre-release. Manual workflow is available in the GitHub Actions interface.

## GitHub Actions Workflow

### Pre-Release on Merge

When a merge occurs on the `main` branch, a **beta** version is automatically created using GitHub Actions. The workflow is triggered by the merge event, ensuring that each change is reflected in a pre-release.

### Manual Release

Final releases are not triggered automatically. Instead, they are initiated manually via the GitHub Actions interface. This allows for flexibility in verifying and ensuring that the beta version is stable before creating an official release.

## Customs scripts
Scripts that are used in the release process are located in the `docker` package. These scripts are used to build Docker images, deploy services, and manage the release process. Check out the [README.md](../packages/docker/README.md) for more details.
`release-it` config is also shared via local packages.

## Roadmap
- add alpha pre-release once development is provisioned
- implement actual deployment to infra as currently only the Docker image is build and pushed
Loading

0 comments on commit a9fa7e8

Please sign in to comment.