Skip to content

Commit

Permalink
setup release automation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Aug 25, 2024
1 parent 2af7814 commit 01261e9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 5 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
publish:
name: Publish release
needs: [build]
# if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -124,7 +124,18 @@ jobs:
with:
pattern: odiff-*.exe
merge-multiple: true
destination-path: npm_package/raw_binaries
path: npm_package/raw_binaries

- run: tree npm_package
- name: Publish npm package
working-directory: npm_package
run: npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create github release
uses: softprops/action-gh-release@v1
with:
files: "npm_package/raw_binaries/*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4 changes: 4 additions & 0 deletions npm_package/bin/odiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

console.error("odiff: seems like a binary executable for your OS wasn't linked. Please verify that postinstsall script run successfully")
process.exit(1);
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions npm_package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "odiff-bin",
"version": "3.1.0",
"author": "Dmitriy Kovalenko <[email protected]>",
"license": "MIT",
"description": "The fastest image difference tool in the world",
"scripts": {
"postinstall": "node ./post_install.js"
},
"types": "odiff.d.ts",
"main": "odiff.js",
"keywords": [
"visual-regression",
"pixelmatch",
"image",
"comparison",
"diff"
]
}
10 changes: 10 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ dune build
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/g" package.json
npm install

sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/g" npm_package/package.json

git commit -m "chore(release): v$VERSION"

git tag "v$VERSION"

git push origin "v$VERSION"

git push

2 changes: 1 addition & 1 deletion test/node-binding.test.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require("path");
const test = require("ava");
const { compare } = require("../bin/node-bindings/odiff");
const { compare } = require("../npm_package/odiff");

const IMAGES_PATH = path.resolve(__dirname, "..", "images");
const BINARY_PATH = path.resolve(
Expand Down
2 changes: 1 addition & 1 deletion test/node-bindings.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compare } from "../bin/node-bindings/odiff";
import { compare } from "../npm_package/odiff";

// allow no options
compare("path1", "path2", "path3")
Expand Down

0 comments on commit 01261e9

Please sign in to comment.