-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (112 loc) · 4.84 KB
/
release_packages.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
name: Release packages
on:
release:
types:
- released
permissions:
contents: read
jobs:
update-homebrew:
name: Update Homebrew Tap
runs-on: ubuntu-latest
steps:
- name: Checkout Salami repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.target_commitish }}
path: salami
- name: Checkout Salami homebrew repo
uses: actions/checkout@v3
with:
repository: petrgazarov/homebrew-salami
path: homebrew_salami
token: ${{ secrets.HOMEBREW_SALAMI_GITHUB_TOKEN }}
- name: Get Salami version
id: salami-version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Generate Homebrew Tap
env:
GH_TOKEN: ${{ github.token }}
run: |
export SALAMI_VERSION="${{ steps.salami-version.outputs.version }}"
gh release download --repo petrgazarov/salami "${SALAMI_VERSION}" -p 'salami*darwin*' -p 'salami*linux*' --skip-existing
for i in \
"darwin x64 SALAMI_DARWIN_X64" \
"darwin arm64 SALAMI_DARWIN_ARM64" \
"linux x64 SALAMI_LINUX_X64" \
"linux arm64 SALAMI_LINUX_ARM64" \
; do
set -- $i
OS="$1"
ARCH="$2"
ENV_VAR="$3"
SHA256="$(sha256sum "salami-${SALAMI_VERSION}-${OS}-${ARCH}" | cut -f1 -d' ')"
SHA256_VAR="${ENV_VAR}_SHA256"
URL_VAR="${ENV_VAR}_URL"
export "${SHA256_VAR}=${SHA256}"
export "${URL_VAR}=https://github.com/petrgazarov/salami/releases/download/${SALAMI_VERSION}/salami-${SALAMI_VERSION}-${OS}-${ARCH}"
done
envsubst '$SALAMI_VERSION,$SALAMI_DARWIN_X64_URL,$SALAMI_DARWIN_X64_SHA256,$SALAMI_DARWIN_ARM64_URL,$SALAMI_DARWIN_ARM64_SHA256,$SALAMI_LINUX_X64_URL,$SALAMI_LINUX_X64_SHA256,$SALAMI_LINUX_ARM64_URL,$SALAMI_LINUX_ARM64_SHA256' < "./salami/.github/templates/salami_tap_template.rb" > ./homebrew_salami/salami.rb
- name: Commit and push updated formula
working-directory: homebrew_salami
run: |
set -euo pipefail
git config user.name petrgazarov
git config user.email [email protected]
git add salami.rb
echo "::group::git diff"
git --no-pager diff
echo "::endgroup::"
git commit -m "Brew formula update for Salami version ${{ steps.salami-version.outputs.version }}"
git push origin HEAD:main
update-chocolatey:
name: Update Chocolatey Package
runs-on: windows-latest
steps:
- name: Get Salami version
id: salami-version
shell: bash
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Checkout Salami repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.target_commitish }}
path: salami
- name: Checkout Salami chocolatey repo
uses: actions/checkout@v3
with:
repository: petrgazarov/salami-chocolatey
path: salami_chocolatey
token: ${{ secrets.CHOCOLATEY_SALAMI_GITHUB_TOKEN }}
- name: Update version in Chocolatey repo
working-directory: salami_chocolatey
shell: bash
run: |
set -euo pipefail
NEW_VERSION="${{ steps.salami-version.outputs.version }}"
sed -i "s|https://github.com/petrgazarov/salami/releases/download/.*/salami-.*-windows-x64|https://github.com/petrgazarov/salami/releases/download/${NEW_VERSION}/salami-${NEW_VERSION}-windows-x64|g" chocolateyInstall.ps1
sed -i "s|<version>.*</version>|<version>${NEW_VERSION}</version>|g" salami.nuspec
- name: Commit and push to Salami chocolatey repo
working-directory: salami_chocolatey
shell: bash
run: |
set -euo pipefail
git config user.name petrgazarov
git config user.email [email protected]
git add chocolateyInstall.ps1 salami.nuspec
echo "::group::git diff"
git --no-pager diff
echo "::endgroup::"
if ! git diff --exit-code; then
git commit -m "Update version to ${{ steps.salami-version.outputs.version }}"
git tag -a "${{ steps.salami-version.outputs.version }}" -m "Chocolatey package update for Salami version ${{ steps.salami-version.outputs.version }}"
git push origin "${{ steps.salami-version.outputs.version }}"
fi
- name: Publish Salami chocolatey package
working-directory: salami_chocolatey
shell: bash
run: |
set -euo pipefail
choco config set --name=defaultPushSource --value=https://push.chocolatey.org/
choco pack
choco push salami.${{ steps.salami-version.outputs.version }}.nupkg -k ${{ secrets.CHOCOLATEY_API_KEY }}