This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(semantic-release): move to dotenv and release.scripts.js
- Loading branch information
1 parent
82507ff
commit a0d82b7
Showing
5 changed files
with
59 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const argv = require("minimist")(process.argv.slice(2)); | ||
const connect = require("simple-git/promise"); | ||
const replace = require("replace-in-file"); | ||
const packageJson = require("./package.json"); | ||
|
||
const success = async () => { | ||
try { | ||
const repo = await connect("."); | ||
const remotes = await repo.getRemotes(true); | ||
const originPush = remotes[0].refs.push; | ||
const authOrigin = originPush.replace( | ||
"https://", | ||
`https://${process.env.GH_TOKEN}@` | ||
); | ||
await repo.checkout("dev"); | ||
await repo.raw(["rebase", "--root", "dev", "--onto", "master"]); | ||
await repo.push("origin", "dev", `--repo=${authOrigin}`); | ||
await repo.push("origin", "master", `--repo=${authOrigin}`); | ||
console.log("Rebase finished."); | ||
} catch (error) { | ||
console.error("Error occurred:", error); | ||
} | ||
}; | ||
|
||
const prepare = async () => { | ||
const options = { | ||
files: "wp-pwa.php", | ||
from: [/Version: \d+\.\d+\.\d+/, /plugin_version = '\d+\.\d+\.\d+'/], | ||
to: [ | ||
`Version: ${packageJson.version}`, | ||
`plugin_version = '${packageJson.version}'` | ||
] | ||
}; | ||
try { | ||
const changes = await replace(options); | ||
console.log("Modified files:", changes.join(", ")); | ||
} catch (error) { | ||
console.error("Error occurred:", error); | ||
} | ||
}; | ||
|
||
(async () => { | ||
if (argv.success) await success(); | ||
else if (argv.prepare) await prepare(); | ||
})(); |