Skip to content

Commit

Permalink
feat: new release workflow (#284)
Browse files Browse the repository at this point in the history
* feat: new release workflow

* fix: bump dev version to 1.4.3

* fix: skip daily generation while no changes
  • Loading branch information
greenhat616 committed Jan 20, 2024
1 parent 71e759a commit 21e17b4
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 34 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: dev # Dev branch
- name: Install Node
uses: actions/setup-node@v4
with:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Dev Build

on:
workflow_dispatch:
# push:
# branches:
# - dev
schedule:
- cron: "15 0 * * *" # 每天 08:15 UTC+8 自动构建
env:
Expand Down Expand Up @@ -32,8 +29,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: dev # Dev branch

- name: install Rust stable
run: rustup install stable --profile minimal && rustup default stable
Expand Down Expand Up @@ -155,8 +150,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: dev # Dev branch
- name: Set Env
run: |
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
Expand All @@ -166,7 +159,6 @@ jobs:
uses: greenhat616/update-tag@v1
with:
tag_name: pre-release
ref: dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
Expand Down Expand Up @@ -195,8 +187,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: dev # Dev branch
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/puiblish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Publish

on:
workflow_dispatch:
inputs:
versionType:
type: choice
description: "<major|minor|patch>"
required: true
default: "patch"
options:
- major
- minor
- patch

jobs:
publish:
name: Publish ${{ inputs.versionType }} release
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Prepare Node
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Install
run: pnpm i
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- id: update-version
shell: bash
name: Bump version
# Use npm because yarn is for some reason not able to output only the version name
run: |
echo "version=$(pnpm run publish)" >> $GITHUB_OUTPUT
git add .
- name: Conventional Changelog Action
id: build-changelog
uses: TriPSs/conventional-changelog-action@v3
with:
github-token: ${{ secrets.github_token }}
git-message: "chore(release): {version} 🤖 [skip ci]"
git-user-name: "github-actions[bot]"
git-user-email: "41898282+github-actions[bot]@users.noreply.github.com"
preset: "conventionalcommits"
tag-prefix: "v"
output-file: "UPDATELOG.md"
release-count: "10"
git-branch: "main"

- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
body: ${{steps.build-changelog.outputs.clean_changelog}}
name: ${{steps.update-version.outputs.version}}
tag_name: ${{steps.build-changelog.outputs.tag}}
# target_commitish: ${{ steps.tag.outputs.sha }}
8 changes: 2 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Release Build

on:
workflow_dispatch:
push:
branches:
- main
release:
types: [published]

env:
CARGO_INCREMENTAL: 0
Expand All @@ -29,8 +27,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main

- name: install Rust stable
run: rustup install stable --profile minimal && rustup default stable
Expand Down
2 changes: 1 addition & 1 deletion backend/tauri/overrides/nightly.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/1.x/tooling/cli/schema.json",
"package": {
"version": "1.4.2"
"version": "1.4.3"
},
"tauri": {
"updater": {
Expand Down
1 change: 0 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"default:rebaseStalePrs",
"group:monorepos"
],
"baseBranches": ["dev"],
"packageRules": [
{
"groupName": "Bundler packages",
Expand Down
13 changes: 11 additions & 2 deletions scripts/generate-latest-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,23 @@ async function main() {
manifest_version: MANIFEST_VERSION,
latest: {},
arch_template: {},
updated_at: new Date().toISOString(),
} as ManifestVersion;
for (const result of results) {
manifest.latest[result.name as SupportedCore] = result.version;
manifest.arch_template[result.name as SupportedCore] = result.archMapping;
}
consola.success("Generated manifest");

await fs.ensureDir(MANIFEST_DIR);
// If no changes, skip writing manifest
const previousManifest = (await fs.readJSON(MANIFEST_VERSION_PATH)) || {};
delete previousManifest.updated_at;
if (JSON.stringify(previousManifest) === JSON.stringify(manifest)) {
consola.success("No changes, skip writing manifest");
return;
}
manifest.updated_at = new Date().toISOString();
consola.success("Generated manifest");

await fs.writeJSON(MANIFEST_VERSION_PATH, manifest, { spaces: 2 });
consola.success("Manifest written");
}
Expand Down
23 changes: 11 additions & 12 deletions scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { execSync } from "child_process";
import fs from "fs-extra";
import path from "node:path";
import packageJson from "../package.json";
import { resolveUpdateLog } from "./updatelog";
import { TAURI_APP_DIR, cwd } from "./utils/env";
import { consola } from "./utils/logger";
// import { consola } from "./utils/logger";

const TAURI_APP_CONF_PATH = path.join(TAURI_APP_DIR, "tauri.conf.json");
const TAURI_NIGHTLY_APP_CONF_PATH = path.join(
Expand Down Expand Up @@ -39,8 +37,8 @@ async function resolvePublish() {
tauriNightlyJson.package.version = nextNightlyVersion;

// 发布更新前先写更新日志
const nextTag = `v${nextVersion}`;
await resolveUpdateLog(nextTag);
// const nextTag = `v${nextVersion}`;
// await resolveUpdateLog(nextTag);

await fs.writeJSON(PACKAGE_JSON_PATH, packageJson, {
spaces: 2,
Expand All @@ -52,13 +50,14 @@ async function resolvePublish() {
spaces: 2,
});

execSync("git add ./package.json");
execSync(`git add ${TAURI_APP_CONF_PATH}`);
execSync(`git commit -m "v${nextVersion}"`);
execSync(`git tag -a v${nextVersion} -m "v${nextVersion}"`);
execSync(`git push`);
execSync(`git push origin v${nextVersion}`);
consola.success(`Publish Successfully...`);
// execSync("git add ./package.json");
// execSync(`git add ${TAURI_APP_CONF_PATH}`);
// execSync(`git commit -m "v${nextVersion}"`);
// execSync(`git tag -a v${nextVersion} -m "v${nextVersion}"`);
// execSync(`git push`);
// execSync(`git push origin v${nextVersion}`);
// consola.success(`Publish Successfully...`);
console.log(nextVersion);
}

resolvePublish();

0 comments on commit 21e17b4

Please sign in to comment.