Skip to content

Commit

Permalink
We can infer identifer, we don't need to specify it (vercel#2032)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Soltis authored Sep 21, 2022
1 parent bce0ded commit 0627cd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@ on:
workflow_dispatch:
inputs:
increment:
description: 'SemVer Increment'
description: "SemVer Increment"
required: true
default: 'prerelease'
default: "prerelease"
type: choice
options:
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
identifier:
description: 'npm Tag'
required: true
default: 'canary'
type: choice
options:
- canary
- latest
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
jobs:
build:
runs-on: macos-latest
Expand Down Expand Up @@ -70,7 +62,7 @@ jobs:

- name: Version
run: |
./scripts/version.js ${{ inputs.increment }} ${{ inputs.identifier }}
./scripts/version.js ${{ inputs.increment }}
cat version.txt
- name: Release
Expand Down
4 changes: 2 additions & 2 deletions scripts/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ const semver = require("semver");

// These values come from the invocation of release.
const increment = process.argv[2];
const identifier = process.argv[3];

// Now we get the current version of the package.
const versionFilePath = path.join(__dirname, "..", "version.txt");
const versionFileContents = fs.readFileSync(versionFilePath, "utf-8");
const [currentVersion] = versionFileContents.split("\n");

// Now that we know current state, figure out what the target state is.
// The `identifier` is unused unless the increment is `pre____`.
// If we're doing a "pre" release, set the identifier to canary
const identifier = increment.startsWith("pre") ? "canary" : "latest";
const newVersion = semver.inc(currentVersion, increment, identifier);

// Parse the output semver identifer to identify which npm tag to publish to.
Expand Down

0 comments on commit 0627cd8

Please sign in to comment.