-
Notifications
You must be signed in to change notification settings - Fork 105
70 lines (62 loc) · 2.6 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
name: Draft Engine Release
on:
workflow_dispatch:
inputs:
wf-run-id:
description: Workflow Run Id to Upload
required: true
default: "latest"
release-tag:
description: Release Name/Tag
required: false
default: ""
jobs:
release:
name: Release Engine
runs-on: ubuntu-latest
steps:
- name: Install Build Dependencies (Common)
run: |
sudo apt-get update -y
sudo apt-get install --fix-missing -y curl unzip
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Download Artifacts
id: dl-artifacts
run: |
if [ "${{ github.event.inputs.wf-run-id }}" == "latest" ]; then
run_id=$(curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -s 'https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-docker.yml/runs?status=success&per_page=1' | jq '.workflow_runs[0].id')
if [ "$run_id" == "null" ]; then
echo "Failed to fetch latest runs"
exit 1
fi
else
run_id="${{ github.event.inputs.wf-run-id }}"
fi
get_code=$(curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${run_id}")
if [ $get_code != 200 ]; then
echo "Failed to fetch run $run_id"
exit 1
fi
echo "Creating release from run $run_id"
artifact_dl_urls=$(curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/${{ github.repository }}/actions/runs/${run_id}/artifacts" | jq ".artifacts[].archive_download_url" | tr -d "\"")
for adl in $artifact_dl_urls; do
curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -L -s -o tmp.zip $adl
unzip tmp.zip
rm tmp.zip
done
if [ "${{ github.event.inputs.release-tag }}" == "" ]; then
filename=$(ls | grep spring | head -n 1)
release_tag=$(echo $filename | cut -d'_' -f1,2,3)
echo "release_tag=${release_tag}" >> "$GITHUB_OUTPUT"
else
echo "release_tag=${{ github.event.inputs.release-tag }}" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: Upload Artifacts As Release
uses: softprops/action-gh-release@v1
with:
files: ./*
tag_name: ${{ steps.dl-artifacts.outputs.release_tag }}
body: "Github Action Upload"
draft: true