-
Notifications
You must be signed in to change notification settings - Fork 428
145 lines (142 loc) · 6.3 KB
/
homebrew.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
139
140
141
142
143
144
145
name: homebrew
on:
release:
types: [released]
jobs:
download-and-archive:
runs-on: ubuntu-latest
steps:
- name: macOS/amd64 binary
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
curl -Lo copilot-darwin-amd64 https://github.com/aws/copilot-cli/releases/download/${version}/copilot-darwin-amd64
cp copilot-darwin-amd64 copilot
chmod +x copilot
tar czf copilot_${semvar}_macOS_amd64.tar.gz copilot
- name: macOS/arm64 binary
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
curl -Lo copilot-darwin-arm64 https://github.com/aws/copilot-cli/releases/download/${version}/copilot-darwin-arm64
cp copilot-darwin-arm64 copilot
chmod +x copilot
tar czf copilot_${semvar}_macOS_arm64.tar.gz copilot
- name: linux/amd64 binary
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
curl -Lo copilot-linux https://github.com/aws/copilot-cli/releases/download/${version}/copilot-linux
cp copilot-linux copilot
chmod +x copilot
tar czf copilot_${semvar}_linux_amd64.tar.gz copilot
- name: linux/arm64 binary
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
curl -Lo copilot-linux-arm64 https://github.com/aws/copilot-cli/releases/download/${version}/copilot-linux-arm64
cp copilot-linux-arm64 copilot
chmod +x copilot
tar czf copilot_${semvar}_linux_arm64.tar.gz copilot
- name: Save archive files
uses: actions/upload-artifact@v2
with:
name: save tar files
path: '*.tar.gz'
retention-days: 7
update-release:
runs-on: ubuntu-latest
needs: download-and-archive
steps:
- name: Download archive files
uses: actions/[email protected]
with:
name: save tar files
- name: Update release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: '*.tar.gz'
create-pr:
runs-on: ubuntu-latest
needs: update-release
permissions:
pull-requests: write
steps:
- name: Download archive files
id: download
uses: actions/[email protected]
with:
name: save tar files
- name: Checkout bottle repo
uses: actions/checkout@v2
with:
repository: 'aws/homebrew-tap'
path: 'homebrew-tap'
- name: Update version
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
tmp=$(mktemp)
jq --arg version "${semvar}" '.version = $version' homebrew-tap/bottle-configs/copilot-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/copilot-cli.json
- name: Update root_url
run: |
tmp=$(mktemp)
version="${GITHUB_REF##*/}"
semvar="${version:1}"
jq --arg version "${version}" --arg semvar "${semvar}" '.bottle.root_url = "https://github.com/aws/copilot-cli/releases/download/" + $version + "/copilot_" + $semvar + "_"' homebrew-tap/bottle-configs/copilot-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/copilot-cli.json
- name: Update sierra
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
sha=$(openssl dgst -sha256 ${{steps.download.outputs.download-path}}/copilot_${semvar}_macOS_amd64.tar.gz | awk '{print $NF}')
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.sierra = "'$sha'"' homebrew-tap/bottle-configs/copilot-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/copilot-cli.json
- name: Update arm64_big_sur
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
sha=$(openssl dgst -sha256 ${{steps.download.outputs.download-path}}/copilot_${semvar}_macOS_arm64.tar.gz | awk '{print $NF}')
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.arm64_big_sur = "'$sha'"' homebrew-tap/bottle-configs/copilot-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/copilot-cli.json
- name: Update linux
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
sha=$(openssl dgst -sha256 ${{steps.download.outputs.download-path}}/copilot_${semvar}_linux_amd64.tar.gz | awk '{print $NF}')
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.linux = "'$sha'"' homebrew-tap/bottle-configs/copilot-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/copilot-cli.json
- name: Update linux_arm
run: |
version="${GITHUB_REF##*/}"
semvar="${version:1}"
sha=$(openssl dgst -sha256 ${{steps.download.outputs.download-path}}/copilot_${semvar}_linux_arm64.tar.gz | awk '{print $NF}')
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.linux_arm = "'$sha'"' homebrew-tap/bottle-configs/copilot-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/copilot-cli.json
- name: Create commits
run: |
cd homebrew-tap
git config user.name 'ecs-cicd-bot'
git config user.email '[email protected]'
git add bottle-configs/copilot-cli.json
git commit -m "chore: upgrade copilot-cli to ${GITHUB_REF##*/}"
- name: Set pull-request variables
id: vars
run: |
echo version="${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
echo pr_title="chore: upgrade copilot-cli to ${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
echo pr_body="Created by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}. @aws/aws-ecs-devx" >> $GITHUB_OUTPUT
- name: Create pull-request
uses: peter-evans/create-pull-request@v3
with:
path: homebrew-tap
delete-branch: true
push-to-fork: ecs-cicd-bot/homebrew-tap
title: ${{ steps.vars.outputs.pr_title }}
body: ${{ steps.vars.outputs.pr_body }}
branch: "upgrade-copilot-${{ steps.vars.outputs.version }}"
token: ${{ secrets.ECS_CICD_BOT }}