Skip to content

Commit

Permalink
ci: set up release workflow for release branch (#243)
Browse files Browse the repository at this point in the history
* fix pr_title workflow

* add test workflow

* update release workflow

* fix action

* fix config

* fix action

* fix [ci skip]

* fix

* fix

* update

* update

* add stage workflow

* fix
  • Loading branch information
rot1024 committed Jun 10, 2022
1 parent 4047436 commit 7e98de9
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 131 deletions.
17 changes: 17 additions & 0 deletions .github/changelog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"prefix": {
"feat": "🚀 Features",
"fix": "🔧 Bug Fixes",
"docs": "📖 Documentation",
"doc": "📖 Documentation",
"perf": "⚡️ Performance",
"refactor": "✨ Refactor",
"style": "🎨 Styling",
"test": "🧪 Testing",
"chore": "Miscellaneous Tasks",
"build": "Miscellaneous Tasks",
"deps": "Miscellaneous Tasks",
"ci": false,
"revert": false
}
}
58 changes: 0 additions & 58 deletions .github/cliff.toml

This file was deleted.

7 changes: 0 additions & 7 deletions .github/pr-title-checker-config.json

This file was deleted.

18 changes: 10 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ on:
workflow_run:
workflows: [ci]
types: [completed]
branches: [main]
branches: [main, release]
jobs:
info:
name: Collect information
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.info.outputs.new_tag }}
branch: ${{ steps.info.outputs.branch }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Get info
Expand All @@ -22,6 +23,7 @@ jobs:
if [[ ! -z "$TAG" ]]; then
echo "::set-output name=new_tag::$TAG"
fi
echo "::set-output name=branch::`git branch --show-current`"
- name: Show info
env:
NEW_TAG: ${{ steps.info.outputs.new_tag }}
Expand All @@ -32,14 +34,14 @@ jobs:
needs:
- info
steps:
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
- uses: actions/checkout@v2
node-version: lts/*
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -62,7 +64,7 @@ jobs:
needs:
- info
- build
if: "!needs.info.outputs.new_tag"
if: ${{ needs.info.outputs.branch == 'main' && !needs.info.outputs.new_tag }}
env:
ARTIFACT: reearth-web.tar.gz
ARTIFACT_NEW: reearth-web_nightly.tar.gz
Expand Down Expand Up @@ -90,7 +92,7 @@ jobs:
needs:
- info
- build
if: needs.info.outputs.new_tag
if: ${{ needs.info.outputs.branch == 'release' && needs.info.outputs.new_tag }}
env:
ARTIFACT: reearth-web.tar.gz
ARTIFACT_NEW: reearth-web_${{ needs.info.outputs.new_tag }}.tar.gz
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI
on:
push:
branches: [main]
branches: [main, release]
tags-ignore: ["*"]
pull_request:
concurrency:
Expand All @@ -12,15 +12,14 @@ jobs:
name: CI
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
- name: Checkout
uses: actions/checkout@v2
node-version: lts/*
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ jobs:
needs: e2e_pre
if: needs.e2e_pre.outputs.result != null
steps:
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: '14.x'
- name: checkout
uses: actions/checkout@v2
node-version: lts/*
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- labeled
- unlabeled
jobs:
check:
pr_title:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
Expand Down
68 changes: 22 additions & 46 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,49 @@ name: Release
on:
workflow_dispatch:
inputs:
custom_tag:
version:
required: false
description: Specify version only when you want to increment the minor and major version (e.g. 1.1.0)
description: 'Next version (NOTE: Switch the branch to "release"!)'
type: choice
default: minor
options:
- patch
- minor
- major
jobs:
release:
name: Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/release'
steps:
- name: Set up git config
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GPT }}
- name: Bump tag version
id: tag
uses: mathieudutour/github-tag-action@v5.6
- id: changelog
name: Generate CHANGELOG
uses: reearth/changelog-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ github.event.inputs.custom_tag }}
dry_run: true
- name: Update version of package.json
version: ${{ github.event.inputs.version }}
repo: ${{ github.repository }}
latest: true
- name: Update package.json version
env:
TAG: ${{ steps.tag.outputs.new_tag }}
VERSION: ${{ steps.changelog.outputs.version }}
run: |
yarn version --no-git-tag-version --new-version ${TAG/v}
- name: Prepare git-cliff
run: touch CHANGELOG.md
- name: Generate changelog
uses: orhun/git-cliff-action@v1
env:
OUTPUT: CHANGELOG.md
with:
config: .github/cliff.toml
args: --verbose --tag ${{ steps.tag.outputs.new_tag }}
- name: Format changelogs
env:
URL: ${{ github.event.repository.html_url }}
run: |
URL=${URL//\//\\\/}
sed -i -E 's/<!-- [0-9]+ -->//g; s/\(#([0-9]+)\)/([#\1]('"$URL"'\/pull\/\1))/g; s/`([a-zA-Z0-9]+)`/[`\1`]('"$URL"'\/commit\/\1)/g' CHANGELOG*.md
- name: Generate CHANGELOG_latest.md
uses: actions/github-script@v5
with:
script: |
const fs = require("fs");
const changelog = fs.readFileSync("CHANGELOG.md", "utf8");
const lines = changelog.split("\n");
const h = lines
.map((l, i) => [l, i])
.filter(l => l[0].startsWith("## "))
.map(l => l[1])
.slice(0, 2);
if (!h.length) throw new Error("failed to get the changelog of the latest version");
const m = lines.slice(h[0] + 1, h[1]).join("\n");
fs.writeFileSync("CHANGELOG_latest.md", m);
- name: Upload latest changelog
yarn version --no-git-tag-version --new-version ${VERSION/v}
- name: Upload latest CHANGELOG
uses: actions/upload-artifact@v2
with:
name: changelog-${{ steps.tag.outputs.new_tag }}
name: changelog-${{ steps.changelog.outputs.version }}
path: CHANGELOG_latest.md
- name: Commit & push
env:
TAG: ${{ steps.tag.outputs.new_tag }}
TAG: ${{ steps.changelog.outputs.version }}
run: |
rm CHANGELOG_latest.md
git add CHANGELOG.md
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Stage
on:
workflow_dispatch:
jobs:
stage:
runs-on: ubuntu-latest
if: github.ref === "refs/heads/main"
steps:
- name: git config
env:
GPT_USER: ${{ secrets.GPT_USER }}
run: |
git config --global user.name $GPT_USER
git config --global pull.rebase false
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GPT }}
- name: Checkout release branch
run: git checkout release
- name: Merge main branch to release branch
run: git merge -X theirs main
- name: Git push
run: git push origin release

0 comments on commit 7e98de9

Please sign in to comment.