-
Notifications
You must be signed in to change notification settings - Fork 208
141 lines (123 loc) · 4.8 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
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Publish Lava Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
release_tag:
description: "The desired tag for the release (e.g. v1.1.0)."
required: true
permissions:
contents: read
jobs:
release:
name: 'release'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}
- name: Fetch all tags
run: |
git fetch --force --tags
- name: Configure Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Run GoReleaser
id: releaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --timeout 90m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Check for existing assests
# id: existing_asset
# run: |
# if [ "${{ github.event.release.assets[0].name }}" = "lavad" ]; then
# echo "URL=${{ github.event.release.assets[0].id }}" >> $GITHUB_OUTPUT
# echo "URL=${{ github.event.release.assets[0].url }}" >> $GITHUB_OUTPUT
# echo "CHECK=true" >> $GITHUB_OUTPUT
# else
# echo "CHECK=false" >> $GITHUB_OUTPUT
# fi
# - name: Upload build to release
# run: |
# upload_binary () {
# echo "Uploading binary to: $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavad/g')"
# curl \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavad)" \
# --data-binary @build/lavad \
# $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavad-${{ github.event.release.tag_name }}-linux-amd64/g')
# curl \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavap)" \
# --data-binary @build/lavap \
# $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavap-${{ github.event.release.tag_name }}-linux-amd64/g')
# curl \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavavisor)" \
# --data-binary @build/lavavisor \
# $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavavisor-${{ github.event.release.tag_name }}-linux-amd64/g')
# }
# delete_binary(){
# echo "Deleting existing binary"
# curl \
# -X DELETE \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# ${{ steps.existing_asset.outputs.URL }}
# }
# if ${{ steps.existing_asset.outputs.CHECK }}; then
# delete_binary
# upload_binary
# else
# upload_binary
# fi
# - name: Check for existing Checksum
# id: existing_checksum
# run: |
# #Get Checksum of new build
# export CHECKSUM=$(sha256sum build/lavad | cut -d " " -f1)
# #Get the existing body
# existing_body=$(curl \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Content-Type: $(file -b --mime-type build/lavad)" \
# ${{ github.event.release.url }} | jq '.body')
# if [[ $existing_body == *"$CHECKSUM"* ]]; then
# echo "CHECK=true" >> $GITHUB_OUTPUT
# echo "Checksum hasn't changed."
# else
# echo "CHECK=false" >> $GITHUB_OUTPUT
# cat <<EOF >> /tmp/body
# $(echo $existing_body | sed '$s/.$//')\r\nChecksum $CHECKSUM"
# EOF
# echo -E "NEW_BODY=$(cat /tmp/body)" >> $GITHUB_OUTPUT
# fi
# - name: Append Binary Checksum
# uses: actions/github-script@v6
# if: ${{ steps.existing_checksum.outputs.CHECK }} == 'false'
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const { data } = await github.rest.repos.updateRelease({
# owner: context.repo.owner,
# repo: context.repo.repo,
# release_id: context.payload.release.id,
# body: ${{ steps.existing_checksum.outputs.NEW_BODY }}
# });