Skip to content

Commit da409cd

Browse files
committed
move to action homebrew
1 parent 2892391 commit da409cd

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

.github/workflows/cd.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,20 @@ jobs:
2929
- run: npm publish # add the package to npm
3030
env:
3131
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
32-
- run: yarn standalone # creates binaries + updates homebrew
32+
- run: yarn standalone # creates binaries
3333
- name: Github Release # adds the binaries to github release
3434
uses: softprops/action-gh-release@v1
3535
with:
3636
files: "standalone/*"
37+
- name: Extract version
38+
id: extract-version
39+
run: |
40+
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
41+
- uses: mislav/bump-homebrew-formula-action@v1
42+
with:
43+
formula-path: hygen.rb
44+
homebrew-tap: jondot/homebrew-tap
45+
download-url: "https://github.com/hygen/releases/download/${{ steps.extract-version.outputs.tag-name }}/hygen.macos.${{ steps.extract-version.outputs.tag-name }}.tar.gz"
46+
commit-message: updating formula for Hygen
47+
env:
48+
COMMITTER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/standalone.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,29 @@ const main = async () => {
3939
console.log('standalone: done.')
4040
console.log((await execa.command(`ls ${wd}`, opts)).stdout)
4141

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

62-
console.log('standalone: publish done.')
63+
console.log('standalone: publish done.')
64+
}
6365
}
6466
}
6567

0 commit comments

Comments
 (0)