-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (133 loc) · 5.43 KB
/
go_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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: "Compile and Release on Tag Push"
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
build-and-release-tag:
if: github.repository == 'playtechnique/templ'
runs-on: ubuntu-22.04
env:
OUTPUT_BINARY: templ
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "checkout"
uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
fetch-depth: 0
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: "checkout again at tag version"
uses: actions/checkout@v3
with:
ref: ${{ steps.previoustag.outputs.tag }}
- name: show we understand previoustag
run: |
echo "<${{ steps.previoustag.outputs.tag }}>"
- name: 'Check if release already exists'
id: check_release
run: |
RELEASE_URL=$(curl -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.previoustag.outputs.tag }}" \
| jq -r ".url" )
if [[ "$RELEASE_URL" != "null" ]]; then
echo "Release already exists. Skipping..."
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: "compile binary"
if: steps.check_release.outputs.exists == 'false'
run: |
GOOS=linux go build -o ${{ env.OUTPUT_BINARY }}-linux
GOOS=darwin GOARCH=amd64 go build -o ${{ env.OUTPUT_BINARY }}-mac-amd64
GOOS=darwin GOARCH=arm64 go build -o ${{ env.OUTPUT_BINARY }}-mac-arm64
GOOS=windows GOARCH=amd64 go build -o ${{ env.OUTPUT_BINARY }}-win-amd64
- name: Release
if: steps.check_release.outputs.exists == 'false'
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.previoustag.outputs.tag }}
release_name: Release ${{ steps.previoustag.outputs.tag }}
- name: Upload linux
if: steps.check_release.outputs.exists == 'false'
id: upload-linux-asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-linux
asset_name: ${{ env.OUTPUT_BINARY }}-linux
asset_content_type: binary
- name: Upload macos amd64
if: steps.check_release.outputs.exists == 'false'
id: upload-macos-asset-amd64
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-mac-amd64
asset_name: ${{ env.OUTPUT_BINARY }}-mac-amd64
asset_content_type: binary
- name: Upload macos arm64
if: steps.check_release.outputs.exists == 'false'
id: upload-macos-asset-arm64
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-mac-arm64
asset_name: ${{ env.OUTPUT_BINARY }}-mac-arm64
asset_content_type: binary
- name: Upload windows arm64
if: steps.check_release.outputs.exists == 'false'
id: upload-windows-asset-arm64
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-win-amd64
asset_name: ${{ env.OUTPUT_BINARY }}-win-amd64
asset_content_type: binary
outputs:
version_tag: ${{ steps.previoustag.outputs.tag }}
release-homebrew:
runs-on: ubuntu-22.04
needs: build-and-release-tag
env:
SOURCE_CODE_URL: https://github.com/${{ github.repository }}/archive/refs/tags/${{ needs.build-and-release-tag.outputs.version_tag }}.tar.gz
steps:
- name: 'Get source code artifact and binary for this version'
run: |
mkdir templ-downloads
cd templ-downloads
curl -LO ${{ env.SOURCE_CODE_URL }}
- name: 'Generate sha256 sum'
id: generate-sha256
run: |
SHA256=$(shasum -a 256 "templ-downloads/templ-${{ needs.build-and-release-tag.outputs.version_tag }}.tar.gz" | awk '{print $1}')
echo "templ sha256 is ${SHA256}"
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: 'Download homebrew-templ'
uses: actions/checkout@v3
with:
repository: 'PlayTechnique/homebrew-templ'
ssh-key: '${{ secrets.HOMEBREWTEMPLSSHKEY }}'
- name: 'show current file system layout'
run: |
ls -ltr
- name: 'Prepare a template file'
run: |
export SHA_VALUE=${{ steps.generate-sha256.outputs.sha256 }}
export URL_VALUE=${{ env.SOURCE_CODE_URL }}
echo "SHA VALUE: ${SHA_VALUE}"
echo "URL VALUE: ${URL_VALUE}"
sed -i "s|sha256.*|sha256: \"$SHA_VALUE\"|" Formula/templ.rb
sed -i "s|url.*|url: \"$URL_VALUE\"|" Formula/templ.rb
- name: "Add new repo file"
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Bot"
git add Formula/templ.rb
git commit -m "Auto-Updater from templ: updating for ${{ needs.build-and-release-tag.outputs.version_tag }}"
git push