-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (105 loc) · 4.19 KB
/
release.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
name: Release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
name: Build and Release Binaries
runs-on: macos-latest
strategy:
matrix:
target: [x86_64-apple-darwin]
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Build the Binary
run: cargo build --release --target ${{ matrix.target }}
- name: Create Release Asset
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/ecs-exec release/
zip -j release/ecs-exec-${{ matrix.target }}.zip release/ecs-exec*
- name: Generate Checksum
id: generate_checksum
run: |
shasum -a 256 release/ecs-exec-${{ matrix.target }}.zip > release/ecs-exec-${{ matrix.target }}.sha256
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: release/ecs-exec-${{ matrix.target }}.zip # Use explicit path, no wildcards
asset_name: ecs-exec-${{ matrix.target }}.zip
asset_content_type: application/zip
- name: Upload Checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: release/ecs-exec-${{ matrix.target }}.sha256
asset_name: ecs-exec-${{ matrix.target }}.sha256
asset_content_type: text/plain
update-homebrew:
name: Update Homebrew Formula
runs-on: macos-latest
needs: build
strategy:
matrix:
target: [ x86_64-apple-darwin ]
steps:
- name: Checkout Homebrew Tap Repository
uses: actions/checkout@v3
with:
persist-credentials: false
repository: kyrylokulyhin/homebrew-cli-tools
token: ${{ secrets.REPO_ACCESS_TOKEN }}
path: homebrew-cli-tools
- name: Download Checksum
run: |
if [ -z "${{ matrix.target }}" ]; then
echo "Target not specified, skipping download"
exit 1
fi
DOWNLOAD_URL="https://github.com/kyrylokulyhin/ecs-exec/releases/download/${{ github.event.release.tag_name }}/ecs-exec-${{ matrix.target }}.sha256"
echo "Downloading checksum from $DOWNLOAD_URL"
curl -L -o ecs-exec-${{ matrix.target }}.sha256 $DOWNLOAD_URL
- name: Check if Formula Exists
run: |
if [ ! -f "homebrew-cli-tools/Formula/ecs-exec.rb" ]; then
echo "Formula file not found!"
exit 1
fi
- name: Update Homebrew Formula
run: |
CHECKSUM=$(awk '{ print $1 }' ecs-exec-${{ matrix.target }}.sha256)
FORMULA_PATH="homebrew-cli-tools/Formula/ecs-exec.rb"
DOWNLOAD_URL="https://github.com/kyrylokulyhin/ecs-exec/releases/download/${{ github.event.release.tag_name }}/ecs-exec-${{ matrix.target }}.zip"
if [ -z "$CHECKSUM" ]; then
echo "Error: SHA256 checksum is empty!"
exit 1
else
echo "SHA256 checksum: $CHECKSUM"
fi
# Replace the URL in the formula
sed -i '' "s|url \".*\"|url \"${DOWNLOAD_URL}\"|" $FORMULA_PATH
# Replace the SHA256 checksum in the formula
sed -i '' "s|sha256 \".*\"|sha256 \"${CHECKSUM}\"|" $FORMULA_PATH
# Replace the version in the formula
sed -i '' "s|version \".*\"|version \"${{ github.event.release.tag_name }}\"|" $FORMULA_PATH
- name: Commit and Push Formula Update
run: |
cd homebrew-cli-tools/
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add Formula/ecs-exec.rb
git commit -m "Update ecs-exec formula to version ${{ github.event.release.tag_name }}"
git push https://kyrylokulyhin:${{ secrets.REPO_ACCESS_TOKEN }}@github.com/kyrylokulyhin/homebrew-cli-tools.git HEAD:main