-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (104 loc) · 4.28 KB
/
webhook-releaser.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: Release Workflow
on:
repository_dispatch:
types: [trigger-release]
# jobs:
# create-release:
# runs-on: ubuntu-latest
# if: github.event.action == 'trigger-release'
# steps:
# - name: Create Release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.event.client_payload.tag_name }}
# release_name: Release ${{ github.event.client_payload.tag_name }}
# draft: false
# prerelease: false
# body: |
# Release details:
# - Tag: ${{ github.event.client_payload.tag_name }}
# - Additional Information: ${{ github.event.client_payload.other_info }}
jobs:
download-and-upload-artifacts:
runs-on: ubuntu-latest
if: github.event.action == 'trigger-release'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Fetch release artifacts
id: fetch-artifacts
env:
GITHUB_TOKEN: ${{ secrets.PAT }} # GitHub automatically creates a GITHUB_TOKEN secret to use in your workflow
OWNER: dashwave # Replace with the owner of the repository
REPO: dw-cli # Replace with the repository name
TAG: ${{ github.event.client_payload.tag_name }} # Replace with the release tag
run: |
mkdir artifacts
cd artifacts
# Get the release information.
RELEASE_DATA=$(curl -sH "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$OWNER/$REPO/releases/tags/$TAG")
# Get the count of assets in the release.
ASSET_COUNT=$(echo $RELEASE_DATA | jq '.assets | length')
# Loop over the assets and download each one.
for (( i=0; i<$ASSET_COUNT; i++ )); do
ASSET_ID=$(echo $RELEASE_DATA | jq ".assets[$i].id")
ASSET_NAME=$(echo $RELEASE_DATA | jq -r ".assets[$i].name")
echo "Downloading asset: $ASSET_NAME (ID: $ASSET_ID)"
# Download the asset.
curl -LJO -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/octet-stream" \
"https://api.github.com/repos/$OWNER/$REPO/releases/assets/$ASSET_ID"
done
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.client_payload.tag_name }} # Replace with your new release tag
release_name: Release ${{ github.event.client_payload.tag_name }} # Replace with your new release name
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/dw_darwin_amd64.tar.gz
asset_name: dw_darwin_amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/dw_darwin_arm64.tar.gz
asset_name: dw_darwin_arm64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/dw_linux_amd64.tar.gz
asset_name: dw_linux_amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/dw_linux_arm64.tar.gz
asset_name: dw_linux_arm64.tar.gz
asset_content_type: application/gzip