Skip to content

Commit

Permalink
chore: update node
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-chillios committed Feb 6, 2024
1 parent 971bc48 commit 02458c5
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 83 deletions.
30 changes: 15 additions & 15 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
name: 'Mobile Version Bump'
description: 'Bump Android & iOS versions'
name: "Mobile Version Bump"
description: "Bump Android & iOS versions"

inputs:
android-project-path:
description: '*Required. The path to the Android project. If not provided, the Android version will not be bumped.'
description: "*Required. The path to the Android project. If not provided, the Android version will not be bumped."
required: false
ios-project-path:
description: '*Required. The path to the iOS project. If not provided, the iOS version will not be bumped.'
description: "*Required. The path to the iOS project. If not provided, the iOS version will not be bumped."
required: false
bump-type:
description: 'The type of bump to perform. Can be one of: major, minor, patch.'
description: "The type of bump to perform. Can be one of: major, minor, patch."
required: false
build-number:
description: 'The build number to use for the iOS version. If not provided, the build number will be incremented by 1.'
description: "The build number to use for the iOS version. If not provided, the build number will be incremented by 1."
required: false
version-code:
description: 'The version code to use for the Android version. If not provided, the version code will be incremented by 1.'
description: "The version code to use for the Android version. If not provided, the version code will be incremented by 1."
required: false

outputs:
android-version:
description: 'The new Android version.'
description: "The new Android version."
android-version-code:
description: 'The new Android version code.'
description: "The new Android version code."
ios-version:
description: 'The new iOS version.'
description: "The new iOS version."
ios-build-number:
description: 'The new iOS build number.'
description: "The new iOS build number."

runs:
using: 'node16'
main: './dist/index.js'
using: "node20"
main: "./dist/index.js"

branding:
color: 'purple'
icon: 'arrow-up-circle'
color: "purple"
icon: "arrow-up-circle"
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "mobile-version-bump-action",
"version": "1.0.0",
"name": "version-bumper",
"version": "2.0.1",
"description": "Github Action to bump Android & iOS versions and build numbers",
"main": "dist/index.js",
"scripts": {
"build": "ncc build ./src/index.ts -s -m -o dist",
"publish": ""
},
"dependencies": {
"@actions/core": "1.10.0",
"@actions/core": "1.10.1",
"@actions/exec": "1.1.1"
},
"devDependencies": {
"@types/node": "18.15.3",
"@vercel/ncc": "0.36.1",
"typescript": "5.0.2"
"@types/node": "20.11.16",
"@vercel/ncc": "0.38.1",
"typescript": "5.3.3"
},
"keywords": [
"github",
Expand Down
65 changes: 39 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ export function bumpAndroidValues({
);
}
if (versionNameLineIndex > 0 || version) {
fileLines[versionNameLineIndex] = version || getVersionNameLine(
fileLines[versionNameLineIndex],
bumpType
);
fileLines[versionNameLineIndex] =
version ||
getVersionNameLine(fileLines[versionNameLineIndex], bumpType);
}

writeFile(gradlePath, fileLines.join("\n"), (error) => {
Expand Down
14 changes: 8 additions & 6 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export const bumpedVersion = (version: string, bumpType: string) => {
const [major, minor, patch] = version.replace(new RegExp('"', 'g'), '').split(".")
const [major, minor, patch] = version
.replace(new RegExp('"', "g"), "")
.split(".");

switch (bumpType) {
case "major":
return `${parseInt(major) + 1}.0.0`
return `${parseInt(major) + 1}.0.0`;
case "minor":
return `${major}.${parseInt(minor) + 1}.0`
return `${major}.${parseInt(minor) + 1}.0`;
case "patch":
return `${major}.${minor}.${parseInt(patch) + 1}`
return `${major}.${minor}.${parseInt(patch) + 1}`;
default:
return version
return version;
}
}
};
39 changes: 22 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
import { setFailed, getInput } from "@actions/core"
import { bumpAndroidValues } from "./android"
import { bumpIosValues } from "./ios"
import { Input } from "./types"
import { setFailed, getInput } from "@actions/core";
import { bumpAndroidValues } from "./android";
import { bumpIosValues } from "./ios";
import { Input } from "./types";

const run = () => {
const androidPath = getInput(Input.AndroidProjectPath)
const iosPath = getInput(Input.IosProjectPath)
const bumpType = getInput(Input.BumpType)
const versionCode = getInput(Input.VersionCode)
const buildNumber = getInput(Input.BuildNumber)
const appVersion = getInput(Input.AppVersion)
const androidPath = getInput(Input.AndroidProjectPath);
const iosPath = getInput(Input.IosProjectPath);
const bumpType = getInput(Input.BumpType);
const versionCode = getInput(Input.VersionCode);
const buildNumber = getInput(Input.BuildNumber);
const appVersion = getInput(Input.AppVersion);

if (androidPath) {
bumpAndroidValues({ version: appVersion, androidPath, versionCode, bumpType })
bumpAndroidValues({
version: appVersion,
androidPath,
versionCode,
bumpType,
});
} else {
console.log("No android path provided. Skipping...")
console.log("No android path provided. Skipping...");
}

if (iosPath) {
bumpIosValues({ version: appVersion, iosPath, buildNumber, bumpType })
bumpIosValues({ version: appVersion, iosPath, buildNumber, bumpType });
} else {
console.log("No ios path provided. Skipping...")
console.log("No ios path provided. Skipping...");
}
}
};

try {
run()
run();
} catch (error) {
setFailed(error.message)
setFailed(error.message);
}
9 changes: 7 additions & 2 deletions src/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { getExecOutput } from "@actions/exec";
import { bumpedVersion } from "./helpers";
import { Output } from "./types";

async function bumpIosVersion(path: string, bumpType: string, version?: string) {
async function bumpIosVersion(
path: string,
bumpType: string,
version?: string
) {
const options = { cwd: path };
const { stdout: currentIosVersion } = await getExecOutput(
"agvtool",
["what-marketing-version", "-terse1"],
options
);
const newVersion = version || bumpedVersion(currentIosVersion.toString().trim(), bumpType);
const newVersion =
version || bumpedVersion(currentIosVersion.toString().trim(), bumpType);

if (newVersion) {
const { stdout: iosVersion } = await getExecOutput(
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export enum Input {
AppVersion = "app-version",
}


export enum Output {
AndroidVersionCode = "android-version-code",
AndroidVersion = "android-version",
Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"compileOnSave": false,
"include": ["src/*"],
"exclude": ["node_modules", "dist"],
"buildOptions": {
"incremental": true
},
"compilerOptions": {
"moduleResolution": "node16"
"module": "ESNext",
"moduleResolution": "Bundler",
"moduleDetection": "force"
}
}

0 comments on commit 02458c5

Please sign in to comment.