-
Notifications
You must be signed in to change notification settings - Fork 6
138 lines (110 loc) · 4.08 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer
name: Build
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-xcode-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-xcode-
- name: build
run: |
ls -n /Applications/ | grep Xcode*
make build
- name: test
run: |
./scripts/code-coverage.sh
create_release:
needs:
- build
runs-on: macos-14
if: github.ref == 'refs/heads/main'
name: Create release
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
sha: ${{ steps.release.outputs.sha }}
upload_url: ${{ steps.release.outputs.upload_url }}
steps:
- id: release
uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple
package-name: sendkeys
changelog-types: |
[
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Documentation","hidden":false},
{"type":"misc","section":"Miscellaneous","hidden":false}
]
create_bottle:
needs:
- create_release
runs-on: macos-14
if: ${{ needs.create_release.outputs.release_created }}
name: Create bottle
outputs:
file: ${{ steps.bottle.outputs.file }}
sha: ${{ steps.bottle.outputs.sha }}
root_url: ${{ steps.bottle.outputs.root_url }}
steps:
- uses: actions/checkout@v4
- id: bottle
name: Create bottle
run: |
./scripts/update-version.sh ${{ needs.create_release.outputs.tag_name }}
./scripts/bottle.sh ${{ needs.create_release.outputs.tag_name }} big_sur
- name: Upload bottle
if: ${{ needs.create_release.outputs.release_created }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./${{ steps.bottle.outputs.file }}
asset_name: ${{ steps.bottle.outputs.file }}
asset_content_type: application/gzip
homebrew:
needs:
- create_release
- create_bottle
runs-on: macos-14
if: ${{ needs.create_release.outputs.release_created }}
name: Update homebrew formula
steps:
- uses: actions/checkout@v4
- name: Update homebrew formula
run: |
git config user.name github-actions[bot]
git config user.email socsieng-github-actions[bot]@users.noreply.github.com
git clone "https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/socsieng/homebrew-tap.git"
cd homebrew-tap
git checkout -B main
formula='Formula/sendkeys.rb'
version=`echo '${{ needs.create_release.outputs.tag_name }}' | sed -E 's/^v//g'`
revision='${{ needs.create_release.outputs.sha }}'
sed_root_url=`echo '${{ needs.create_bottle.outputs.root_url }}' | sed 's/\\//\\\\\//g'`
sha='${{ needs.create_bottle.outputs.sha }}'
sed -E -i "" "s/tag: \"[^\"]+\"/tag: \"v$version\"/g" $formula
sed -E -i "" "s/revision: \"[^\"]+\"/revision: \"$revision\"/g" $formula
sed -E -i "" "s/version \"[^\"]+\"/version \"$version\"/g" $formula
sed -E -i "" "s/root_url \"[^\"]+\"/root_url \"$sed_root_url\"/g" $formula
sed -E -i "" "s/sha256 cellar: :any_skip_relocation, big_sur: \"[^\"]+\"/sha256 cellar: :any_skip_relocation, big_sur: \"$sha\"/g" $formula
git commit -am "chore: update sendkeys to ${{ needs.create_release.outputs.tag_name }}"
git push origin main