forked from smithy-lang/smithy
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (115 loc) · 5.01 KB
/
update-brew.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
name: update-brew
on:
release:
types: [released]
workflow_dispatch: # on button click
env:
release_prefix: https://github.com/smithy-lang/smithy/releases/download
jobs:
download-and-save:
runs-on: ubuntu-latest
steps:
- name: mac
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-darwin-x86_64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: mac-arm
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-darwin-aarch64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: linux
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-linux-x86_64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: linux-arm
if: startsWith(github.ref, 'refs/tags/')
run: |
version="${GITHUB_REF##*/}"
hash_url="${{ env.release_prefix }}/${version}/smithy-cli-linux-aarch64.tar.gz"
echo $hash_url
curl -fJLO $hash_url.sha256
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: brew-artifacts
path: '*.sha256'
retention-days: 7
create-pr:
runs-on: ubuntu-latest
needs: download-and-save
permissions:
pull-requests: write
steps:
- name: Get artifacts
id: download
uses: actions/download-artifact@v3
with:
name: brew-artifacts
- name: Checkout bottle repo
uses: actions/checkout@v4
with:
repository: 'smithy-lang/homebrew-tap'
path: 'homebrew-tap'
ref: 'main'
token: ${{ secrets.PR_TOKEN }}
- name: Update version
run: |
version="${GITHUB_REF##*/}"
tmp=$(mktemp)
jq --arg version "${version}" '.version = $version' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update root_url
run: |
version="${GITHUB_REF##*/}"
tmp=$(mktemp)
jq --arg release_url "${{ env.release_prefix }}" --arg version "${version}" '.bottle.root_url = "\($release_url)/\($version)/smithy-cli"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update mac
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-darwin-x86_64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.sierra = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update mac-arm
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-darwin-aarch64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.arm64_big_sur = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update linux
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-linux-x86_64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.linux = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Update linux-arm
run: |
version="${GITHUB_REF##*/}"
sha=$(cut -d " " -f1 ${{steps.download.outputs.download-path}}/smithy-cli-linux-aarch64.tar.gz.sha256)
tmp=$(mktemp)
jq --arg sha "$sha" '.bottle.sha256.linux_arm = "'$sha'"' homebrew-tap/bottle-configs/smithy-cli.json > "$tmp" && mv "$tmp" homebrew-tap/bottle-configs/smithy-cli.json
- name: Set up new git branch for version bump
working-directory: homebrew-tap
run: |
git config user.name 'smithy-automation'
git config user.email '[email protected]'
git checkout -b "automation/bump-smithy-cli-version/${GITHUB_REF##*/}"
- name: Create PR
working-directory: homebrew-tap
run: |
git add bottle-configs/smithy-cli.json
git commit -m "chore: upgrade smithy-cli to ${GITHUB_REF##*/}"
git push --set-upstream origin "automation/bump-smithy-cli-version/${GITHUB_REF##*/}"
gh pr create \
--title "[Automation] chore: upgrade smithy-cli to ${GITHUB_REF##*/}" \
--body "Created by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
--base main
env:
GITHUB_TOKEN: ${{ secrets.PR_TOKEN }}