diff --git a/README.md b/README.md index fb30458..61acbcb 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,8 @@ If different flakes have different release strategies, for example one flake use | `tag` | The Git tag to use for non-rolling releases. This must be the character `v` followed by a SemVer version, such as `v0.1.1`. | string | | | | `rev` | The Git revision SHA to use for non-rolling releases. | string | | | | `rolling` | For untagged releases, use a [rolling versioning scheme][rolling]. When this is enabled, the default versioning scheme is `0.1.[commit count]+rev-[git sha]`. To customize the [SemVer] minor version, set the `rolling-minor` option. | Boolean | | `false` | -| `rolling-minor` | Specify the [SemVer] minor version of your [rolling releases][rolling]. All releases will follow the versioning scheme `0.[rolling-minor].[commit count]+rev-[git sha]`. | string | | | +| `rolling-major` | Specify the [SemVer] major version of your [rolling releases][rolling]. All releases will follow the versioning scheme `[rolling-major].[rolling-minor].[commit count]+rev-[git sha]`. | string | | | +| `rolling-minor` | Specify the [SemVer] minor version of your [rolling releases][rolling]. All releases will follow the versioning scheme `[rolling-major].[rolling-minor].[commit count]+rev-[git sha]`. | string | | | | `git-root` | The root directory of your Git repository. | relative path | | `.` | | `extra-labels` | `flakehub-push` automatically uses the GitHub repo's topics as labels. This `extra-labels` parameter enables you to add extra labels beyond that as a comma-separated string. Only alphanumeric characters and hyphens are allowed in labels and the maximum length of labels is 50 characters. You can specify a maximum of 20 extra labels, and have a maximum of 25 labels, including those that we retrieve from GitHub. Any labels after the 25th will be ignored. | string | | `""` | | `spdx-expression` | A valid SPDX license expression. This will be used in place of what GitHub claims your repository's `spdxIdentifier` is. | string | | `""` | diff --git a/action.yaml b/action.yaml index ec8ed2f..d1d17aa 100644 --- a/action.yaml +++ b/action.yaml @@ -36,8 +36,12 @@ inputs: description: The Git revision SHA to use for non-rolling releases. required: false default: null + rolling-major: + description: "Specify the SemVer major version of your rolling releases. All releases will follow the versioning scheme '[rolling-major].[rolling-minor].[commit count]+rev-[git sha]'" + required: false + default: null rolling-minor: - description: "Specify the SemVer minor version of your rolling releases. All releases will follow the versioning scheme '0.[rolling-minor].[commit count]+rev-[git sha]'" + description: "Specify the SemVer minor version of your rolling releases. All releases will follow the versioning scheme '[rolling-major].[rolling-minor].[commit count]+rev-[git sha]'" required: false default: null rolling: diff --git a/dist/index.js b/dist/index.js index eda822e..fd63956 100644 --- a/dist/index.js +++ b/dist/index.js @@ -108413,6 +108413,7 @@ var FlakeHubPushAction = class extends DetSysAction { this.rolling = inputs_exports.getBool("rolling"); this.mirror = inputs_exports.getBool("mirror"); this.name = inputs_exports.getStringOrNull("name"); + this.rollingMajor = inputs_exports.getNumberOrNull("rolling-major"); this.rollingMinor = inputs_exports.getNumberOrNull("rolling-minor"); } async main() { @@ -108459,6 +108460,9 @@ var FlakeHubPushAction = class extends DetSysAction { if (this.name !== null) { env.FLAKEHUB_PUSH_NAME = this.name; } + if (this.rollingMajor !== null) { + env.FLAKEHUB_PUSH_ROLLING_MAJOR = this.rollingMajor.toString(); + } if (this.rollingMinor !== null) { env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString(); } diff --git a/dist/index.js.map b/dist/index.js.map index f29168c..39cd25a 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport * as actionsGithub from \"@actions/github\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\nconst FACT_PUSH_ATTEMPT_FROM_PR = \"push_attempt_from_pr\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_REV?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n GITHUB_CONTEXT?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private rev: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private myFlakeIsTooBig: boolean;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.rev = inputs.getString(\"rev\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.myFlakeIsTooBig = inputs.getBool(\"my-flake-is-too-big\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_REV = this.rev;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString();\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n env.GITHUB_CONTEXT = JSON.stringify(actionsGithub.context);\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n if (actionsGithub.context.payload.pull_request) {\n actionsCore.setFailed(\n \"flakehub-push cannot be triggered from pull requests\",\n );\n this.addFact(FACT_PUSH_ATTEMPT_FROM_PR, true);\n return;\n }\n\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n ignoreReturnCode: true,\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,YAAY,mBAAmB;AAC/B,SAAS,cAAc,cAAc;AAErC,IAAM,0BAA0B;AA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UAAM,WAAW,MAAkB,iBAAK,oBAAoB,CAAC,GAAG;AAAA,MAC9D,kBAAkB;AAAA,MAClB,KAAK;AAAA,QACH,GAAG;AAAA,QACH,GAAG,QAAQ;AAAA;AAAA,MACb;AAAA,IACF,CAAC;AAED,QAAI,aAAa,GAAG;AAClB,WAAK,YAAY,yBAAyB;AAAA,QACxC;AAAA,MACF,CAAC;AACD,MAAY,sBAAU,yBAAyB,QAAQ,WAAW;AAAA,IACpE,OAAO;AACL,MAAY,iBAAK,0CAA0C;AAAA,IAC7D;AAAA,EACF;AACF;AAEA,SAAS,OAAa;AACpB,MAAI,mBAAmB,EAAE,QAAQ;AACnC;AAEA,KAAK;","names":[]} \ No newline at end of file +{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport * as actionsGithub from \"@actions/github\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\nconst FACT_PUSH_ATTEMPT_FROM_PR = \"push_attempt_from_pr\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_REV?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MAJOR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n GITHUB_CONTEXT?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private rev: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private myFlakeIsTooBig: boolean;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMajor: number | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.rev = inputs.getString(\"rev\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.myFlakeIsTooBig = inputs.getBool(\"my-flake-is-too-big\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMajor = inputs.getNumberOrNull(\"rolling-major\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_REV = this.rev;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString();\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n env.GITHUB_CONTEXT = JSON.stringify(actionsGithub.context);\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMajor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MAJOR = this.rollingMajor.toString();\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n if (actionsGithub.context.payload.pull_request) {\n actionsCore.setFailed(\n \"flakehub-push cannot be triggered from pull requests\",\n );\n this.addFact(FACT_PUSH_ATTEMPT_FROM_PR, true);\n return;\n }\n\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n ignoreReturnCode: true,\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,YAAY,mBAAmB;AAC/B,SAAS,cAAc,cAAc;AAErC,IAAM,0BAA0B;AAEhC,IAAM,4BAA4B;AA0BlC,IAAM,qBAAN,cAAiC,aAAa;AAAA,EAsB5C,cAAc;AACZ,UAAM;AAAA,MACJ,MAAM;A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;AAAA,IACjE;AAEA,UAAM,WAAW,MAAkB,iBAAK,oBAAoB,CAAC,GAAG;AAAA,MAC9D,kBAAkB;AAAA,MAClB,KAAK;AAAA,QACH,GAAG;AAAA,QACH,GAAG,QAAQ;AAAA;AAAA,MACb;AAAA,IACF,CAAC;AAED,QAAI,aAAa,GAAG;AAClB,WAAK,YAAY,yBAAyB;AAAA,QACxC;AAAA,MACF,CAAC;AACD,MAAY,sBAAU,yBAAyB,QAAQ,WAAW;AAAA,IACpE,OAAO;AACL,MAAY,iBAAK,0CAA0C;AAAA,IAC7D;AAAA,EACF;AACF;AAEA,SAAS,OAAa;AACpB,MAAI,mBAAmB,EAAE,QAAQ;AACnC;AAEA,KAAK;","names":[]} \ No newline at end of file diff --git a/src/cli/mod.rs b/src/cli/mod.rs index c87cf1b..e47fc8e 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -31,6 +31,8 @@ pub(crate) struct FlakeHubPushCli { pub(crate) tag: OptionString, #[clap(long, env = "FLAKEHUB_PUSH_REV", value_parser = StringToNoneParser, default_value = "")] pub(crate) rev: OptionString, + #[clap(long, env = "FLAKEHUB_PUSH_ROLLING_MAJOR", value_parser = U64ToNoneParser, default_value = "")] + pub(crate) rolling_major: OptionU64, #[clap(long, env = "FLAKEHUB_PUSH_ROLLING_MINOR", value_parser = U64ToNoneParser, default_value = "")] pub(crate) rolling_minor: OptionU64, #[clap(long, env = "FLAKEHUB_PUSH_ROLLING", value_parser = EmptyBoolParser, default_value_t = false)] @@ -405,21 +407,31 @@ impl FlakeHubPushCli { } pub(crate) fn release_version(&self, git_ctx: &GitContext) -> Result { - let rolling_prefix_or_tag = match (self.rolling_minor.0.as_ref(), &self.tag.0) { - (Some(_), _) if !self.rolling => { + let rolling_prefix_or_tag = match ( + self.rolling_major.0.as_ref(), + self.rolling_minor.0.as_ref(), + &self.tag.0, + ) { + (Some(_), None, _) | (None, Some(_), _) | (Some(_), Some(_), _) if !self.rolling => { return Err(eyre!( - "You must enable `rolling` to upload a release with a specific `rolling-minor`." + "You must enable `rolling` to upload a release with a specific `rolling-major` and/or `rolling-minor`." )); } - (Some(minor), _) => format!("0.{minor}"), - (None, _) if self.rolling => DEFAULT_ROLLING_PREFIX.to_string(), - (None, Some(tag)) => { + (None, Some(minor), _) => format!("0.{minor}"), + (Some(major), Some(minor), _) => format!("{major}.{minor}"), + (None, None, _) if self.rolling => DEFAULT_ROLLING_PREFIX.to_string(), + (None, None, Some(tag)) => { let version_only = tag.strip_prefix('v').unwrap_or(tag); // Ensure the version respects semver semver::Version::from_str(version_only).wrap_err_with(|| eyre!("Failed to parse version `{tag}` as semver, see https://semver.org/ for specifications"))?; tag.to_string() } - (None, None) => { + (Some(_), None, _) => { + return Err(eyre!( + "You cannot set `--rolling-major` without `--rolling-minor`" + )); + } + (None, None, None) => { return Err(eyre!("Could not determine tag or rolling minor version, `--tag`, `GITHUB_REF_NAME`, or `--rolling-minor` must be set")); } }; @@ -428,14 +440,15 @@ impl FlakeHubPushCli { return Err(eyre!("Could not determine commit count, this is normally determined via the `--git-root` argument or via the GitHub API")); }; - let rolling_minor_with_postfix_or_tag = if self.rolling_minor.0.is_some() || self.rolling { - format!( - "{rolling_prefix_or_tag}.{}+rev-{}", - commit_count, git_ctx.revision_info.revision - ) - } else { - rolling_prefix_or_tag.to_string() // This will always be the tag since `self.rolling_prefix` was empty. - }; + let rolling_minor_with_postfix_or_tag = + if self.rolling_major.0.is_some() || self.rolling_minor.0.is_some() || self.rolling { + format!( + "{rolling_prefix_or_tag}.{}+rev-{}", + commit_count, git_ctx.revision_info.revision + ) + } else { + rolling_prefix_or_tag.to_string() // This will always be the tag since `self.rolling_prefix` was empty. + }; Ok(rolling_minor_with_postfix_or_tag) } diff --git a/ts/index.ts b/ts/index.ts index 3e89209..b10cd22 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -26,6 +26,7 @@ type ExecutionEnvironment = { FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string; FLAKEHUB_PUSH_ROLLING?: string; FLAKEHUB_PUSH_MIRROR?: string; + FLAKEHUB_PUSH_ROLLING_MAJOR?: string; FLAKEHUB_PUSH_ROLLING_MINOR?: string; GITHUB_CONTEXT?: string; }; @@ -49,6 +50,7 @@ class FlakeHubPushAction extends DetSysAction { private rolling: boolean; private mirror: boolean; private name: string | null; + private rollingMajor: number | null; private rollingMinor: number | null; constructor() { @@ -78,6 +80,7 @@ class FlakeHubPushAction extends DetSysAction { this.rolling = inputs.getBool("rolling"); this.mirror = inputs.getBool("mirror"); this.name = inputs.getStringOrNull("name"); + this.rollingMajor = inputs.getNumberOrNull("rolling-major"); this.rollingMinor = inputs.getNumberOrNull("rolling-minor"); } @@ -140,6 +143,10 @@ class FlakeHubPushAction extends DetSysAction { env.FLAKEHUB_PUSH_NAME = this.name; } + if (this.rollingMajor !== null) { + env.FLAKEHUB_PUSH_ROLLING_MAJOR = this.rollingMajor.toString(); + } + if (this.rollingMinor !== null) { env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString(); }