Skip to content

Commit

Permalink
Update package and release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpyder committed Apr 12, 2024
1 parent b1d4210 commit a9d7c27
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 40 deletions.
52 changes: 30 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build bs-atdgen-generator
name: Build rescript-atdgen-generator

on: [push, pull_request]

Expand All @@ -7,17 +7,17 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 12
- uses: actions/checkout@v2
node-version: 'lts'
- uses: actions/checkout@v4

- run: npm install -g esy

- name: Try to restore install cache
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.esy/source
key: source-${{ hashFiles('**/index.json') }}
Expand All @@ -31,7 +31,7 @@ jobs:

- name: Try to restore build cache
id: deps-cache-macos
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
key: build-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
Expand All @@ -44,7 +44,7 @@ jobs:
run: npm install
working-directory: test

- if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
- if: matrix.os != 'windows-latest'
name: (Mac, Linux) Get atdgen path
id: atdgen-path-nix
run: echo "::set-output name=path::$(esy which atdgen)"
Expand All @@ -54,7 +54,7 @@ jobs:
id: atdgen-path-win
run: echo "::set-output name=path::$(esy where atdgen)"

- if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
- if: matrix.os != 'windows-latest'
name: "(Mac, Linux) [Test] Generate bsconfig.json"
env:
ATDGEN_PATH: ${{ steps.atdgen-path-nix.outputs.path }}
Expand All @@ -77,7 +77,7 @@ jobs:
run: npm install @jchavarri/bs-atdgen-generator --save-dev
working-directory: test

- if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
- if: matrix.os != 'windows-latest'
name: "(Mac, Linux) [Test] Generate bsconfig.json for published version"
env:
ATDGEN_PATH: ${{ steps.atdgen-path-nix.outputs.path }}
Expand All @@ -99,18 +99,18 @@ jobs:
run: npm run build
working-directory: test

- if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
- if: matrix.os != 'windows-latest'
name: (Mac, Linux) Upload artifacts ${{ matrix.os }}
# if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: ${{ steps.atdgen-path-nix.outputs.path }}

- if: matrix.os == 'windows-latest'
name: (Mac, Linux) Upload artifacts ${{ matrix.os }}
# if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: ${{ steps.atdgen-path-win.outputs.path }}
Expand All @@ -126,28 +126,35 @@ jobs:
name: (only on release) Prepublish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 12

- name: Download linux artifacts
if: success()
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: ubuntu-latest
path: binaries/linux

- name: Download macOS artifacts
- name: Download macOS x64 artifacts
if: success()
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: macos-latest
name: macos-13
path: binaries/darwin

- name: Download macOS arm64 artifacts
if: success()
uses: actions/download-artifact@v4
with:
name: macos-latest
path: binaries/darwin-arm64

- name: Download windows artifacts
if: success()
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: windows-latest
path: binaries/windows
Expand All @@ -160,13 +167,14 @@ jobs:
ls -la binaries/darwin
ls -la binaries/windows
ls -la binaries/linux
mv binaries/darwin-arm64/atdgen exe/bs-atdgen-generator-darwin-arm64.exe
mv binaries/darwin/atdgen exe/bs-atdgen-generator-darwin-x64.exe
mv binaries/windows/atdgen.exe exe/bs-atdgen-generator-win-x64.exe
mv binaries/linux/atdgen exe/bs-atdgen-generator-linux-x64.exe
- name: Upload artifacts ${{ matrix.os }}
- name: Upload release artifacts
# if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Release
path: exe
14 changes: 4 additions & 10 deletions copyPlatformBinaryInPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,20 @@ if (platform === "win32") {
platform = "win";
}

if (platform === "darwin" && arch === "arm64") {
// use rosetta until an Apple Silicon build is available
// https://github.com/actions/virtual-environments/issues/2187
arch = "x64"
}

copyBinary(`exe/bs-atdgen-generator-${platform}-${arch}.exe`, "atdgen");
copyBinary(`exe/rescript-atdgen-generator-${platform}-${arch}.exe`, "atdgen");

function copyBinary(filename, destFilename) {
var supported = fs.existsSync(filename);

if (!supported) {
console.error("bs-atdgen-generator does not support this platform :(");
console.error("rescript-atdgen-generator does not support this platform :(");
console.error("");
console.error(
"bs-atdgen-generator comes prepacked as built binaries to avoid large"
"rescript-atdgen-generator comes prepacked as built binaries to avoid large"
);
console.error("dependencies at build-time.");
console.error("");
console.error("If you want bs-atdgen-generator to support this platform natively,");
console.error("If you want rescript-atdgen-generator to support this platform natively,");
console.error(
"please open an issue at our repository, linked above. Please"
);
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"name": "@jchavarri/bs-atdgen-generator",
"name": "rescript-atdgen-generator",
"version": "0.1.0",
"description": "Atdgen prebuilt binaries for 3 major OS platforms.",
"author": "Javier Chávarri <[email protected]>",
"author": "Andrew Herron",
"license": "MIT",
"keywords": [
"reasonml",
"reason",
"bucklescript",
"rescript",
"ocaml",
"atdgen",
"decoding",
Expand All @@ -18,12 +16,15 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jchavarri/bs-atdgen-generator.git"
"url": "https://github.com/TheSpyder/rescript-atdgen-generator.git"
},
"scripts": {
"preinstall": "node ./copyPlatformBinaryInPlace.js"
},
"publishConfig": {
"access": "public"
}
},
"contributors": [
"Javier Chávarri <[email protected]>"
]
}
2 changes: 1 addition & 1 deletion test/makeBsconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const atdgenPath = process.argv[2];

const bsconfigJson = JSON.stringify(
{
name: "bs-atdgen-generator-integration-test",
name: "rescript-atdgen-generator-integration-test",
generators: [
{
name: "atd_t",
Expand Down

0 comments on commit a9d7c27

Please sign in to comment.