Skip to content

Commit

Permalink
fix: set access rights when building package
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Oct 22, 2024
1 parent 27b1ae7 commit e4197a5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,21 @@ jobs:
if [[ "${{ matrix.arch }}" == "x64" ]]; then
mkdir -p ./bin/linux/x64
cp target/x86_64-unknown-linux-gnu/release/todoctor ./bin/linux/x64/todoctor
chmod +x ./bin/linux/x64/todoctor
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
mkdir -p ./bin/linux/arm64
cp target/aarch64-unknown-linux-gnu/release/todoctor ./bin/linux/arm64/todoctor
chmod +x ./bin/linux/arm64/todoctor
fi
elif [[ "${{ matrix.platform }}" == "macos-latest" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
mkdir -p ./bin/macos/x64
cp target/x86_64-apple-darwin/release/todoctor ./bin/macos/x64/todoctor
chmod +x ./bin/macos/x64/todoctor
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
mkdir -p ./bin/macos/arm64
cp target/aarch64-apple-darwin/release/todoctor ./bin/macos/arm64/todoctor
chmod +x ./bin/macos/arm64/todoctor
fi
fi
shell: bash
Expand Down Expand Up @@ -168,6 +172,20 @@ jobs:
name: todoctor-windows-latest-x64
path: .

- name: Set Execute Permissions on Binaries
run: |
chmod +x ./bin/linux/x64/todoctor || true
chmod +x ./bin/linux/arm64/todoctor || true
chmod +x ./bin/macos/x64/todoctor || true
chmod +x ./bin/macos/arm64/todoctor || true
- name: Verify Binary Permissions
run: |
ls -l ./bin/linux/x64/todoctor || true
ls -l ./bin/linux/arm64/todoctor || true
ls -l ./bin/macos/x64/todoctor || true
ls -l ./bin/macos/arm64/todoctor || true
- name: Create GitHub Release
run: pnpm run ci:changelog
env:
Expand Down
3 changes: 0 additions & 3 deletions bin/todoctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ let binaryPath = path.join(dirname, relativePath)

if (!fs.existsSync(binaryPath)) {
console.error(`Binary not found: ${binaryPath}`)
console.error(
'Please ensure that the postinstall script has run successfully.',
)
process.exit(1)
}

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"build": "pnpm run /^build:/",
"build:lib": "cargo build --release && node ./scripts/build.js",
"build:preview": "vite build",
"postinstall": "node ./scripts/postinstall.js",
"release": "pnpm release:check && pnpm release:version",
"release:check": "pnpm test && pnpm run build",
"release:version": "changelogen --output changelog.md --release --push",
Expand Down Expand Up @@ -57,8 +56,7 @@
"files": [
"./bin",
"./build",
"./dist",
"./scripts"
"./dist"
],
"devDependencies": {
"@azat-io/eslint-config-typescript": "^1.10.0",
Expand Down
7 changes: 2 additions & 5 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (!platformName || !archName) {
let binaryName = platform === 'win32' ? 'todoctor.exe' : 'todoctor'

let sourcePath = path.join(dirname, '..', 'target', 'release', binaryName)
let destDir = path.join(dirname, platformName, archName)
let destDir = path.join(dirname, '../bin/', platformName, archName)
let destPath = path.join(destDir, binaryName)

if (!fs.existsSync(destDir)) {
Expand All @@ -40,10 +40,7 @@ if (!fs.existsSync(destDir)) {

try {
fs.copyFileSync(sourcePath, destPath)

if (platform !== 'win32') {
fs.chmodSync(destPath, 0o755)
}
fs.chmodSync(destPath, 0o755)
} catch (error) {
console.error(`Error copying file: ${error.message}`)
process.exit(1)
Expand Down
15 changes: 0 additions & 15 deletions scripts/postinstall.js

This file was deleted.

0 comments on commit e4197a5

Please sign in to comment.