Skip to content

Commit

Permalink
Rename release targets and add linux-aarch64 (#559)
Browse files Browse the repository at this point in the history
* Add target for linux-aarch64

I'm unsure if this will work in the build workflow.

* Update asset names and update npm and vscode to use new names

* Fix win name for npm-bin

* Fix condition for artifact alias

* Update pyproject to use new formatting

* Make utils.ts prettier
  • Loading branch information
IamTheFij committed Sep 12, 2022
1 parent e8fc691 commit 133393c
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 21 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +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
Expand Down Expand Up @@ -89,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
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ build-backend = "pseudo_builder"

[tool.release-gitter]
extract-files = ["stylua"]
format = "stylua-{system}{arch}.zip"
format = "stylua-{system}-{arch}.zip"
exec = "chmod +x stylua"
[tool.release-gitter.map-arch]
x86_64 = ""
arm64 = "-aarch64"
arm64 = "aarch64"
[tool.release-gitter.map-system]
Darwin = "macos"
Windows = "win64"
Windows = "windows"
Linux = "linux"
11 changes: 8 additions & 3 deletions stylua-npm-bin/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const SUPPORTED_PLATFORMS = [
{
platform: "win32",
arch: "x64",
name: "stylua-win64",
name: "stylua-windows-x86_64",
},
{
platform: "darwin",
arch: "x64",
name: "stylua-macos",
name: "stylua-macos-x86_64",
},
{
platform: "darwin",
Expand All @@ -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",
},
];

Expand Down
15 changes: 10 additions & 5 deletions stylua-vscode/src/test/suite/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
33 changes: 27 additions & 6 deletions stylua-vscode/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,43 @@ 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(-[\\dw\\-\\.]+)?-" + platformPattern + "(-" + archPattern + ")?.zip"
);
};

export const getAssetFilenamePattern = () => {
return getAssetFilenamePatternForPlatform(os.platform());
return getAssetFilenamePatternForPlatform(os.platform(), process.arch);
};

export const getDesiredVersion = (): string => {
Expand Down

0 comments on commit 133393c

Please sign in to comment.