mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
ci: Fix daily alpha workflow to just create the next alpha
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f2070a1e4c
commit
54e7f10ca5
83
.github/workflows/daily-alpha.yml
vendored
83
.github/workflows/daily-alpha.yml
vendored
@ -4,11 +4,7 @@ on:
|
||||
- cron: 0 0 30 * 1-5 # At 12:30am UTC work day
|
||||
workflow_dispatch: # for testing
|
||||
jobs:
|
||||
tag:
|
||||
outputs:
|
||||
tagname: v${{ steps.version.outputs.VERSION }}
|
||||
version: ${{ steps.version.outputs.VERSION }}
|
||||
continue: ${{ steps.create-branch.outputs.CONTINUE }}
|
||||
create-alpha-release-pr:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@ -22,81 +18,10 @@ jobs:
|
||||
- name: Install deps
|
||||
run: |
|
||||
npm install
|
||||
sudo apt-get install -y ripgrep
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Bump version
|
||||
id: version
|
||||
run: |
|
||||
npm run --workspace @k8slens/bump-version-for-cron build
|
||||
npm run --workspace @k8slens/bump-version-for-cron bump -- --path packages/core/package.json
|
||||
- name: Check if branch already exists
|
||||
id: check-branch
|
||||
run: git ls-remote --exit-code --tags origin v${{ steps.version.outputs.VERSION }}
|
||||
continue-on-error: true
|
||||
- name: Create branch and tag and push
|
||||
id: create-branch
|
||||
run: |
|
||||
# failure means that the tag doesn't exist so we should create it
|
||||
if [ ${{ steps.check-branch.outcome }} != 'failure' ]; then
|
||||
echo "CONTINUE=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config --global user.email "bot@k8slens.dev"
|
||||
git config --global user.name "k8slens bot"
|
||||
|
||||
git checkout -b release/v${{ steps.version.outputs.VERSION }}
|
||||
git add .
|
||||
git commit -sm "Release ${{ steps.version.outputs.VERSION }}"
|
||||
git tag v${{ steps.version.outputs.VERSION }}
|
||||
git push origin v${{ steps.version.outputs.VERSION }}
|
||||
echo "CONTINUE=true" >> "$GITHUB_OUTPUT"
|
||||
create_release:
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
version: ${{ needs.tag.outputs.version }}
|
||||
needs: [tag]
|
||||
if: ${{ needs.tag.outputs.continue == 'true' }}
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Create GitHub release
|
||||
uses: softprops/action-gh-release@v1
|
||||
id: create_release
|
||||
- name: Create PR
|
||||
run: npm run create-release-pr
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ needs.tag.outputs.tagname }}
|
||||
name: ${{ needs.tag.outputs.tagname }}
|
||||
generate_release_notes: true
|
||||
prerelease: true
|
||||
release_packages:
|
||||
needs: [create_release]
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: v${{ needs.create_release.outputs.version }}
|
||||
- name: Use Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16.x"
|
||||
registry-url: "https://npm.pkg.github.com"
|
||||
- name: Build package
|
||||
shell: bash
|
||||
run: |
|
||||
npm ci
|
||||
npm run build
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Release to GitHub NPM registry
|
||||
run: |
|
||||
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
|
||||
npx lerna \
|
||||
publish from-package \
|
||||
--no-push \
|
||||
--no-git-tag-version \
|
||||
--yes \
|
||||
--dist-tag cron
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
BUMP_PACKAGE_ARGS: -- --conventional-commits --conventional-prerelease --yes
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -3879,10 +3879,6 @@
|
||||
"resolved": "packages/technical-features/application/electron-main",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@k8slens/bump-version-for-cron": {
|
||||
"resolved": "packages/bump-version-for-cron",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@k8slens/button": {
|
||||
"resolved": "packages/ui-components/button",
|
||||
"link": true
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/swcrc",
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
},
|
||||
"target": "es2022"
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "@k8slens/bump-version-for-cron",
|
||||
"version": "6.5.0-alpha.4",
|
||||
"description": "CLI to bump the version to during a cron daily alpha release",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist/",
|
||||
"build": "swc ./src/index.ts -d ./dist",
|
||||
"bump": "node ./dist/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"dependencies": {
|
||||
"arg": "^5.0.2",
|
||||
"semver": "^7.3.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "^0.1.62",
|
||||
"@swc/core": "^1.3.53",
|
||||
"@types/node": "^16.18.24",
|
||||
"@types/semver": "^7.3.13",
|
||||
"rimraf": "^4.4.1"
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
import * as child_process from "child_process";
|
||||
import { readFile, writeFile } from "fs/promises";
|
||||
import semver from "semver";
|
||||
import { promisify } from "util";
|
||||
import arg from "arg";
|
||||
|
||||
const { SemVer } = semver;
|
||||
|
||||
const exec = promisify(child_process.exec);
|
||||
|
||||
const args = arg({
|
||||
"--path": String,
|
||||
});
|
||||
|
||||
const versionJsonPath = args["--path"];
|
||||
|
||||
if (!versionJsonPath) {
|
||||
throw new Error("Missing required '--path'");
|
||||
}
|
||||
|
||||
try {
|
||||
const packageJson = JSON.parse(await readFile(versionJsonPath, "utf-8"));
|
||||
|
||||
const { stdout: gitRevParseOutput } = await exec("git rev-parse --short HEAD");
|
||||
const currentHash = gitRevParseOutput.trim();
|
||||
|
||||
const currentVersion = new SemVer(packageJson.version);
|
||||
|
||||
const partialVersion = `${currentVersion.major}.${currentVersion.minor}.${currentVersion.patch}`;
|
||||
const prereleasePart = `cron.${currentHash}`;
|
||||
const newVersion = `${partialVersion}-${prereleasePart}`;
|
||||
|
||||
await writeFile(
|
||||
versionJsonPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
...packageJson,
|
||||
version: newVersion,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
if (process.env.GITHUB_OUTPUT) {
|
||||
await writeFile(process.env.GITHUB_OUTPUT, `VERSION=${newVersion}`, {
|
||||
flag: "a+",
|
||||
});
|
||||
}
|
||||
|
||||
await exec(`npm run bump-version ${newVersion} -- --yes`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"outDir": "dist/",
|
||||
"paths": {
|
||||
"*": [
|
||||
"node_modules/*",
|
||||
"types/*"
|
||||
]
|
||||
},
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
]
|
||||
}
|
||||
@ -79,8 +79,9 @@ async function fetchAllGitTags(): Promise<string[]> {
|
||||
}
|
||||
|
||||
function bumpPackageVersions() {
|
||||
const bumpPackages = spawn("npm", ["run", "bump-version"], {
|
||||
stdio: "inherit"
|
||||
const bumpPackages = spawn(`npm run bump-version ${process.env.BUMP_PACKAGE_ARGS ?? ""}`, {
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
});
|
||||
const cleaners: (() => void)[] = [
|
||||
() => bumpPackages.stdout?.unpipe(),
|
||||
@ -153,7 +154,7 @@ async function createReleaseBranchAndCommit(prBase: string, version: SemVer, prB
|
||||
const prBranch = `release/v${version.format()}`;
|
||||
|
||||
await pipeExecFile("git", ["checkout", "-b", prBranch]);
|
||||
await pipeExecFile("git", ["add", "packages/*/package.json", "package-lock.json"]);
|
||||
await pipeExecFile("git", ["add", "."]);
|
||||
await pipeExecFile("git", ["commit", "-sm", `Release ${version.format()}`]);
|
||||
await pipeExecFile("git", ["push", "--set-upstream", "origin", prBranch]);
|
||||
|
||||
@ -354,6 +355,12 @@ async function createRelease(): Promise<void> {
|
||||
}
|
||||
|
||||
const selectedPrs = await pickRelevantPrs(relevantPrs, isMasterBranch);
|
||||
|
||||
if (selectedPrs.length === 0) {
|
||||
console.log(`No PRs have been found relating to ${previousReleasedVersion}, stopping...`);
|
||||
return;
|
||||
}
|
||||
|
||||
const prBody = formatChangelog(previousReleasedVersion, selectedPrs);
|
||||
|
||||
if (!isMasterBranch) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user