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 Sep 27, 2024
1 parent b39b057 commit 2ac91c7
Show file tree
Hide file tree
Showing 50 changed files with 4,012 additions and 162 deletions.
5 changes: 3 additions & 2 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"billing",
"provider",
"deployment",
"certificate",
"dx"
"dx",
"release",
"certificate"
]
]
}
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/docker-build-deploy-web.yml

This file was deleted.

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 ${{ secrets.API_REGISTRY }}
npm run release -w apps/deploy-web -- --preRelease=beta -f --verbose --ci -r ${{ secrets.WEB_REGISTRY }}
74 changes: 74 additions & 0 deletions .github/workflows/release-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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:
- stable
- beta
default: stable
required: true

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
npm run release -w apps/${{ github.event.inputs.app }} -- $pre_release --verbose --ci -r ${{ secrets.API_REGISTRY }}
2 changes: 0 additions & 2 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
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if [[ "$CI" != "true" ]]; then
npm run update-apps-local-deps
git add --all
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)
- [How to run](#how-to-run)
- [Database Structure](#database-structure)
- [Release Workflow](./doc/release-workflow.md)

# Quick start

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")
9 changes: 9 additions & 0 deletions apps/api/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dependencies": {
"@akashnetwork/database": "1.0.0",
"@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 @@ -28,7 +28,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 @@ -95,7 +96,10 @@
},
"devDependencies": {
"@akashnetwork/dev-config": "*",
"@akashnetwork/docker": "*",
"@akashnetwork/releaser": "*",
"@faker-js/faker": "^8.4.1",
"@release-it/conventional-changelog": "github:ygrishajev/conventional-changelog#feature/tag-prefix",
"@types/http-assert": "^1.5.5",
"@types/http-errors": "^2.0.4",
"@types/jest": "^29.5.12",
Expand All @@ -119,6 +123,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/api/src/services/external/githubService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { cacheKeys, cacheResponse } from "@src/caching/helpers";
import { Auditor, ProviderAttributesSchema } from "@src/types/provider";
import { env } from "@src/utils/env";


export function getOctokit() {
const githubPAT = env.GITHUB_PAT;

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 @@ -113,6 +114,7 @@
"@keplr-wallet/types": "^0.12.111",
"@next/bundle-analyzer": "^14.0.1",
"@playwright/test": "^1.45.0",
"@release-it/conventional-changelog": "github:ygrishajev/conventional-changelog#feature/tag-prefix",
"@types/auth0": "^2.35.3",
"@types/file-saver": "^2.0.5",
"@types/js-yaml": "^4.0.5",
Expand All @@ -132,6 +134,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
8 changes: 8 additions & 0 deletions apps/indexer/mvm.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"@akashnetwork/database": "1.0.0"
},
"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 2ac91c7

Please sign in to comment.