From e92ca547c4a3cb7d65a10edace64f22569f997bc Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Wed, 31 Aug 2022 13:43:13 -0700 Subject: [PATCH 1/6] Add target for linux-aarch64 I'm unsure if this will work in the build workflow. --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 28a417b2..45380053 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,9 @@ jobs: - os: ubuntu-18.04 artifact-name: stylua-linux cargo-target: x86_64-unknown-linux-gnu + - os: ubuntu-18.04 + artifact-name: stylua-linux-aarch64 + cargo-target: aarch64-unknown-linux-gnu - os: macos-latest artifact-name: stylua-macos cargo-target: x86_64-apple-darwin From 37d7deab984238881acc78a2de7d19fb619b32a6 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 8 Sep 2022 14:37:46 -0700 Subject: [PATCH 2/6] Update asset names and update npm and vscode to use new names --- .github/workflows/release.yml | 21 ++++++++++++--- pyproject.toml | 4 +-- stylua-npm-bin/binary.js | 11 +++++--- stylua-vscode/package-lock.json | 4 +-- stylua-vscode/src/test/suite/util.test.ts | 15 +++++++---- stylua-vscode/src/util.ts | 31 ++++++++++++++++++----- 6 files changed, 65 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45380053..b57afe8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,16 +28,19 @@ jobs: matrix: include: - os: windows-latest - artifact-name: stylua-win64 + artifact-name: stylua-windows-x86_64 + artifact-alias: stylua-win64 cargo-target: x86_64-pc-windows-msvc - os: ubuntu-18.04 - artifact-name: stylua-linux + artifact-name: stylua-linux-x86_64 + artifact-alias: stylua-linux cargo-target: x86_64-unknown-linux-gnu - os: ubuntu-18.04 artifact-name: stylua-linux-aarch64 cargo-target: aarch64-unknown-linux-gnu - os: macos-latest - artifact-name: stylua-macos + artifact-name: stylua-macos-x86_64 + artifact-alias: stylua-macos cargo-target: x86_64-apple-darwin - os: macos-latest artifact-name: stylua-macos-aarch64 @@ -92,6 +95,18 @@ jobs: asset_name: ${{ matrix.artifact-name }}.zip asset_content_type: application/zip + # TODO: Remove this after deprecation notice + - name: Upload Binary to Release aliases + if: ${{ matrix.artifact-alias == "" }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: release.zip + asset_name: ${{ matrix.artifact-alias }}.zip + asset_content_type: application/zip + release_cargo: name: Publish to cargo runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index d4a806b7..6b26dc75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,9 @@ build-backend = "pseudo_builder" [tool.release-gitter] extract-files = ["stylua"] -format = "stylua-{system}.zip" +format = "stylua-{system}-{arch}.zip" exec = "chmod +x stylua" [tool.release-gitter.map-system] Darwin = "macos" -Windows = "win64" +Windows = "windows" Linux = "linux" diff --git a/stylua-npm-bin/binary.js b/stylua-npm-bin/binary.js index 365be0e7..94d369d7 100644 --- a/stylua-npm-bin/binary.js +++ b/stylua-npm-bin/binary.js @@ -14,12 +14,12 @@ const SUPPORTED_PLATFORMS = [ { platform: "win32", arch: "x64", - name: "stylua-win64", + name: "stylua-win-x86_64", }, { platform: "darwin", arch: "x64", - name: "stylua-macos", + name: "stylua-macos-x86_64", }, { platform: "darwin", @@ -29,7 +29,12 @@ const SUPPORTED_PLATFORMS = [ { platform: "linux", arch: "x64", - name: "stylua-linux", + name: "stylua-linux-x86_64", + }, + { + platform: "linux", + arch: "arm64", + name: "stylua-linux-aarch64", }, ]; diff --git a/stylua-vscode/package-lock.json b/stylua-vscode/package-lock.json index 1166f84c..67aa89a8 100644 --- a/stylua-vscode/package-lock.json +++ b/stylua-vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "stylua", - "version": "1.2.0", + "version": "1.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "stylua", - "version": "1.2.0", + "version": "1.3.2", "license": "MPL-2.0", "dependencies": { "ignore": "^5.1.8", diff --git a/stylua-vscode/src/test/suite/util.test.ts b/stylua-vscode/src/test/suite/util.test.ts index 7f86454f..8eee5594 100644 --- a/stylua-vscode/src/test/suite/util.test.ts +++ b/stylua-vscode/src/test/suite/util.test.ts @@ -2,18 +2,23 @@ import * as assert from "assert"; import { getAssetFilenamePatternForPlatform } from "../../util"; suite("Utilities testing", () => { - test("asset filename pattern matches name with version", () => { - const pattern = getAssetFilenamePatternForPlatform("win32"); + test("asset filename pattern matches legacy name with version", () => { + const pattern = getAssetFilenamePatternForPlatform("win32", "x64"); assert(pattern.test("stylua-0.12.2-win64.zip")); }); - test("asset filename pattern matches name without version", () => { - const pattern = getAssetFilenamePatternForPlatform("win32"); + test("asset filename pattern matches legacy name without version", () => { + const pattern = getAssetFilenamePatternForPlatform("win32", "x64"); assert(pattern.test("stylua-win64.zip")); }); + test("asset filename pattern matches name with version and machine", () => { + const pattern = getAssetFilenamePatternForPlatform("win32", "x64"); + assert(pattern.test("stylua-windows-x86_64.zip")); + }); + test("asset filename pattern does not match for wrong platform", () => { - const pattern = getAssetFilenamePatternForPlatform("win32"); + const pattern = getAssetFilenamePatternForPlatform("win32", "x64"); assert.strictEqual(pattern.test("stylua-linux.zip"), false); }); }); diff --git a/stylua-vscode/src/util.ts b/stylua-vscode/src/util.ts index 97f79a9e..01224079 100644 --- a/stylua-vscode/src/util.ts +++ b/stylua-vscode/src/util.ts @@ -16,22 +16,41 @@ export const getDownloadOutputFilename = () => { }; export const getAssetFilenamePatternForPlatform = ( - platform: NodeJS.Platform + platform: string, + machine: string, ) => { + var platformPattern: string switch (platform) { case "win32": - return /stylua(-[\d\w\-\.]+)?-win64.zip/; + platformPattern = "(windows|win64)"; + break; case "linux": - return /stylua(-[\d\w\-\.]+)?-linux.zip/; + platformPattern = "linux"; + break; case "darwin": - return /stylua(-[\d\w\-\.]+)?-macos.zip/; + platformPattern = "macos"; + break; default: - throw new Error("Platform not supported"); + throw new Error("platform not supported"); } + + var archPattern: string + switch (machine) { + case "arm64": + archPattern = "aarch64"; + break; + case "x64": + archPattern = "x86_64"; + break; + default: + archPattern = ""; + } + + return new RegExp("stylua(-[\\d\w\\-\\.]+)?-" + platformPattern + "(-" + archPattern + ")?.zip"); }; export const getAssetFilenamePattern = () => { - return getAssetFilenamePatternForPlatform(os.platform()); + return getAssetFilenamePatternForPlatform(os.platform(), process.arch); }; export const getDesiredVersion = (): string => { From a25f7013b791f1290524ea835ffd1ed1ea3be66f Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 8 Sep 2022 15:08:04 -0700 Subject: [PATCH 3/6] Fix win name for npm-bin --- stylua-npm-bin/binary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stylua-npm-bin/binary.js b/stylua-npm-bin/binary.js index 94d369d7..69e225e1 100644 --- a/stylua-npm-bin/binary.js +++ b/stylua-npm-bin/binary.js @@ -14,7 +14,7 @@ const SUPPORTED_PLATFORMS = [ { platform: "win32", arch: "x64", - name: "stylua-win-x86_64", + name: "stylua-windows-x86_64", }, { platform: "darwin", From ab2e141f7b903154928daea1b80b60c342890599 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Sun, 11 Sep 2022 19:22:18 -0700 Subject: [PATCH 4/6] Fix condition for artifact alias --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b57afe8d..eb7c5a5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -97,7 +97,7 @@ jobs: # TODO: Remove this after deprecation notice - name: Upload Binary to Release aliases - if: ${{ matrix.artifact-alias == "" }} + if: ${{ matrix.artifact-alias != "" }} uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1bc6c6f130d90500cfabfcd33662e33b4604982b Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Sun, 11 Sep 2022 19:22:33 -0700 Subject: [PATCH 5/6] Update pyproject to use new formatting --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 6b26dc75..d3fc578a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,8 @@ build-backend = "pseudo_builder" extract-files = ["stylua"] format = "stylua-{system}-{arch}.zip" exec = "chmod +x stylua" +[tool.release-gitter.map-arch] +arm64 = "aarch64" [tool.release-gitter.map-system] Darwin = "macos" Windows = "windows" From 704f9230079657c2dcc692a631b078bdc2fa2652 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Sun, 11 Sep 2022 19:46:11 -0700 Subject: [PATCH 6/6] Make utils.ts prettier --- stylua-vscode/src/util.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stylua-vscode/src/util.ts b/stylua-vscode/src/util.ts index 01224079..6b22fd44 100644 --- a/stylua-vscode/src/util.ts +++ b/stylua-vscode/src/util.ts @@ -17,9 +17,9 @@ export const getDownloadOutputFilename = () => { export const getAssetFilenamePatternForPlatform = ( platform: string, - machine: string, + machine: string ) => { - var platformPattern: string + var platformPattern: string; switch (platform) { case "win32": platformPattern = "(windows|win64)"; @@ -34,7 +34,7 @@ export const getAssetFilenamePatternForPlatform = ( throw new Error("platform not supported"); } - var archPattern: string + var archPattern: string; switch (machine) { case "arm64": archPattern = "aarch64"; @@ -43,10 +43,12 @@ export const getAssetFilenamePatternForPlatform = ( archPattern = "x86_64"; break; default: - archPattern = ""; + archPattern = ""; } - return new RegExp("stylua(-[\\d\w\\-\\.]+)?-" + platformPattern + "(-" + archPattern + ")?.zip"); + return new RegExp( + "stylua(-[\\dw\\-\\.]+)?-" + platformPattern + "(-" + archPattern + ")?.zip" + ); }; export const getAssetFilenamePattern = () => {