Skip to content

Commit

Permalink
move to action homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot committed Feb 28, 2022
1 parent 2892391 commit da409cd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ jobs:
- run: npm publish # add the package to npm
env:
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
- run: yarn standalone # creates binaries + updates homebrew
- run: yarn standalone # creates binaries
- name: Github Release # adds the binaries to github release
uses: softprops/action-gh-release@v1
with:
files: "standalone/*"
- name: Extract version
id: extract-version
run: |
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
- uses: mislav/bump-homebrew-formula-action@v1
with:
formula-path: hygen.rb
homebrew-tap: jondot/homebrew-tap
download-url: "https://github.com/hygen/releases/download/${{ steps.extract-version.outputs.tag-name }}/hygen.macos.${{ steps.extract-version.outputs.tag-name }}.tar.gz"
commit-message: updating formula for Hygen
env:
COMMITTER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42 changes: 22 additions & 20 deletions scripts/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,29 @@ const main = async () => {
console.log('standalone: done.')
console.log((await execa.command(`ls ${wd}`, opts)).stdout)

console.log('standalone: publishing to homebrew tap...')
const matches = (
await execa.command(`shasum -a 256 ${wd}/hygen.macos.v${v}.tar.gz`, opts)
).stdout.match(/([a-f0-9]+)\s+/)
if (matches && matches.length > 1) {
const sha = matches[1]
await fs.writeFile('/tmp/hygen.rb', brewFormula(sha, v)) // eslint-disable-line @typescript-eslint/no-use-before-define
const cmd = [
`cd /tmp`,
`git clone git://${repo} brew-tap`,
`cd brew-tap`,
`mv /tmp/hygen.rb .`,
`git config user.email [email protected]`,
`git config user.name 'Dotan Nahum'`,
`git add .`,
`git commit -m 'hygen: auto-release'`,
`git push https://${process.env.GITHUB_TOKEN}@${repo}`,
].join(' && ')
await execa.command(cmd, opts)
if (process.env.MANUAL_HB_PUBLISH) {
console.log('standalone: publishing to homebrew tap...')
const matches = (
await execa.command(`shasum -a 256 ${wd}/hygen.macos.v${v}.tar.gz`, opts)
).stdout.match(/([a-f0-9]+)\s+/)
if (matches && matches.length > 1) {
const sha = matches[1]
await fs.writeFile('/tmp/hygen.rb', brewFormula(sha, v)) // eslint-disable-line @typescript-eslint/no-use-before-define
const cmd = [
`cd /tmp`,
`git clone git://${repo} brew-tap`,
`cd brew-tap`,
`mv /tmp/hygen.rb .`,
`git config user.email [email protected]`,
`git config user.name 'Dotan Nahum'`,
`git add .`,
`git commit -m 'hygen: auto-release'`,
`git push https://${process.env.GITHUB_TOKEN}@${repo}`,
].join(' && ')
await execa.command(cmd, opts)

console.log('standalone: publish done.')
console.log('standalone: publish done.')
}
}
}

Expand Down

0 comments on commit da409cd

Please sign in to comment.