Skip to content

Commit

Permalink
use a build id
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Dec 21, 2023
1 parent f4b6b79 commit 8ef7211
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ inputs:
shaAsVersion:
description: 'whether to use the commit SHA as the version for the updater JSON file or not.'
default: false
buildIdAsVersion:
description: 'whether to use a custom CI based build id as the version for the updater JSON file or not.'
default: false
updaterJsonPreferNsis:
description: 'whether the action will use the NSIS (setup.exe) or WiX (.msi) bundles for the updater JSON if both types exist. Will default to false for Tauri v1 and true for Tauri v2+'
updaterJsonKeepUniversal:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { existsSync } from 'fs';
import { resolve, dirname, basename } from 'path';
import { basename, dirname, resolve } from 'path';

import * as core from '@actions/core';
import { context } from '@actions/github';
import stringArgv from 'string-argv';

import { buildProject } from './build';
import { createRelease } from './create-release';
import { uploadAssets as uploadReleaseAssets } from './upload-release-assets';
import { uploadVersionJSON } from './upload-version-json';
import { buildProject } from './build';
import { execCommand, getInfo, getTargetInfo } from './utils';

import type { Artifact, BuildOptions, InitOptions } from './types';
Expand All @@ -27,6 +27,7 @@ async function run(): Promise<void> {
const includeDebug = core.getBooleanInput('includeDebug');
const includeUpdaterJson = core.getBooleanInput('includeUpdaterJson');
const shaAsVersion = core.getBooleanInput('shaAsVersion');
const buildIdAsVersion = core.getBooleanInput('buildIdAsVersion');
const updaterJsonKeepUniversal = core.getBooleanInput(
'updaterJsonKeepUniversal',
);
Expand Down Expand Up @@ -108,6 +109,10 @@ async function run(): Promise<void> {
const targetInfo = getTargetInfo(targetPath);
const info = getInfo(projectPath, targetInfo, configArg);

const githubRunId = context.runId;
const githubRunNumber = context.runNumber;
const buildId = `${githubRunId}${githubRunNumber}`;

if (tagName && !releaseId) {
const templates = [
{
Expand All @@ -122,6 +127,10 @@ async function run(): Promise<void> {
key: '__SHA__',
value: context.sha,
},
{
key: '__BUILD_ID__',
value: buildId,
},
{
key: '__BRANCH__',
value: context.ref.replace('refs/heads/', ''),
Expand Down Expand Up @@ -184,7 +193,11 @@ async function run(): Promise<void> {
await uploadVersionJSON({
owner,
repo,
version: shaAsVersion ? context.sha.substring(0, 7) : info.version,
version: shaAsVersion
? context.sha.substring(0, 7)
: buildIdAsVersion
? buildId
: info.version,
notes: body,
tagName,
releaseId,
Expand Down

0 comments on commit 8ef7211

Please sign in to comment.