Skip to content

Commit

Permalink
Make version a required input
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMorganz committed Dec 3, 2022
1 parent d5e28cb commit 7b40065
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ GitHub token. Required since the binary is downloaded from GitHub releases (to s

The arguments to pass to the StyLua binary

#### `version` (Optional)
#### `version` (Required)

The version of StyLua to use. Follows semver syntax.
If not specified, installs the latest release.
**It is recommended to pin your version so that updates to StyLua don't lead to unwanted changes in the action without explicitly updating.**
Alternatively, supply `latest` to use the latest available release.

**NOTE: using `latest` may cause the action to fail if StyLua updates and the formatting changes!**

Based off https://github.com/Roblox/setup-foreman, licensed under [MIT](https://github.com/Roblox/setup-foreman/blob/master/LICENSE.txt)
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ inputs:
description: 'CLI Arguments to pass to StyLua'
required: true
version:
description: 'The version of StyLua to run'
description: 'The version of StyLua to run. Use `latest` to pull the latest version'
required: true
runs:
using: 'node16'
main: 'dist/index.js'
10 changes: 2 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ async function run(): Promise<void> {
core.debug(`Set version: "${versionString}", resolved as ${version}`)

let releases
if (!version || versionString === '' || versionString === 'latest') {
if (versionString !== 'latest') {
core.warning(
'No version provided, or version provided is malformed, using latest release version. We recommend pinning the version explicitly to handle changes in formatting'
)
}

if (!version || versionString === 'latest') {
releases = await stylua.getReleases(token)
const latestVersion = stylua.getLatestVersion(releases)
if (!latestVersion) {
Expand All @@ -31,7 +25,7 @@ async function run(): Promise<void> {

// See if we already have the tool installed
core.debug(`Looking for cached version of binary with version ${version}`)
const styluaDirectory = tc.find('stylua', version)
const styluaDirectory = tc.find('stylua', version ?? versionString)
if (styluaDirectory) {
core.debug(`Found cached version of stylua: ${styluaDirectory}`)
core.addPath(styluaDirectory)
Expand Down

0 comments on commit 7b40065

Please sign in to comment.