-
Notifications
You must be signed in to change notification settings - Fork 6
75 lines (61 loc) · 2.63 KB
/
release.yaml
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
name: Create a new release and update latest
on:
release:
types: [created]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Enable Corepack
run: |
corepack enable
corepack prepare yarn@4.5.0 --activate
- name: Install dependencies
run: yarn install
- name: Build and bundle
run: |
cd apps/agent
yarn bundle
- name: Rename bundle
run: mv apps/agent/dist/*.tgz apps/agent/dist/agent-${{ github.event.release.tag_name }}.tgz
- 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: ./apps/agent/dist/agent-${{ github.event.release.tag_name }}.tgz
asset_name: agent-${{ github.event.release.tag_name }}.tgz
asset_content_type: application/gzip
- name: Copy asset for latest
run: cp apps/agent/dist/agent-${{ github.event.release.tag_name }}.tgz apps/agent/dist/agent-latest.tgz
- name: Update latest release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete existing 'latest' tag
git push --delete origin latest || true
# Create new 'latest' tag
git tag -f latest ${{ github.sha }}
git push -f origin latest
# Get the upload URL for the 'latest' release
upload_url=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/latest" \
| jq -r '.upload_url' | sed 's/{?name,label}//g')
# If 'latest' release doesn't exist, create it
if [ "$upload_url" = "null" ]; then
response=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-d '{"tag_name": "latest", "name": "Latest Release", "body": "This is always the latest release"}' \
"https://api.github.com/repos/${{ github.repository }}/releases")
upload_url=$(echo "$response" | jq -r '.upload_url' | sed 's/{?name,label}//g')
fi
# Upload the asset to the 'latest' release
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/gzip" \
--data-binary @apps/agent/dist/agent-latest.tgz \
"${upload_url}?name=agent-latest.tgz"