Skip to content

Commit 494f99a

Browse files
authored
Publish GitHub Releases (#136)
## Description Publishes GitHub Releases for both version tags and pushes to main. ## Why is this needed Publishing on main to the latest release gives us a url we can use for sandbox until a new release is cut if we want to run sandbox with bleeding edge hook builds. Publishing on version tags (`v*`) removes some friction to creating releases and hopefully opens us up for more frequent releases. ## How Has This Been Tested? I simulated many of the scenarios on my fork, see the action runs for it https://github.com/mmlb/tinkerbell-hook/actions. ## How are existing users impacted? What migration steps/scripts do we need? Usable hooks w/o needing to build locally + hopefully more frequent tagged releases.
2 parents 29be915 + 53ecc61 commit 494f99a

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
validation:
1111
runs-on: ubuntu-20.04
12+
outputs:
13+
commitid: ${{steps.commitid.outputs.short}}
1214
steps:
1315
- name: Setup Dynamic Env
1416
run: |
@@ -61,3 +63,85 @@ jobs:
6163
with:
6264
name: hook-${{steps.commitid.outputs.short}}
6365
path: out/${{steps.commitid.outputs.short}}/rel/hook_*.tar.gz
66+
67+
publish-release-latest:
68+
runs-on: ubuntu-20.04
69+
if: github.ref == 'refs/heads/main'
70+
needs: validation
71+
steps:
72+
- name: Checkout code
73+
uses: actions/checkout@v3
74+
75+
- name: Download Artifact
76+
uses: actions/download-artifact@v3
77+
with:
78+
name: hook-${{needs.validation.outputs.commitid}}
79+
80+
- name: Delete Tag
81+
run: |
82+
git tag -d latest || echo "no local tag to delete"
83+
git push origin :latest -f || echo "no remote tag to delete"
84+
85+
- name: Generate Release Notes
86+
run: |
87+
generated_release_notes=$(gh api 'repos/{owner}/{repo}/releases/generate-notes' -F tag_name=latest --jq .body)
88+
cat >>"$GITHUB_ENV" <<-EOF
89+
RELEASE_NOTES<<RELEASE_NOTES_EOF
90+
# :warning: :rotating_light: :boom: Note!!! :boom: :rotating_light: :warning:
91+
92+
The uploaded files will be updated on the next merge to main, as such download them before use to avoid surprises.
93+
94+
---
95+
Commit: ${{needs.validation.outputs.commitid}}
96+
---
97+
98+
$generated_release_notes
99+
RELEASE_NOTES_EOF
100+
EOF
101+
env:
102+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
103+
104+
- name: Update Tag
105+
uses: rickstaa/action-create-tag@v1
106+
with:
107+
tag: latest
108+
message: "Latest development build"
109+
110+
- name: Update latest release
111+
uses: softprops/action-gh-release@v1
112+
with:
113+
name: Hook Latest Development Build
114+
body: ${{env.RELEASE_NOTES}}
115+
files: hook_*.tar.gz
116+
prerelease: true
117+
tag_name: latest
118+
119+
publish-release-tag:
120+
runs-on: ubuntu-20.04
121+
if: startsWith(github.ref, 'refs/tags/v')
122+
needs: validation
123+
steps:
124+
- name: Checkout code
125+
uses: actions/checkout@v3
126+
127+
- name: Download Artifact
128+
uses: actions/download-artifact@v3
129+
with:
130+
name: hook-${{needs.validation.outputs.commitid}}
131+
132+
- name: Generate Release Notes
133+
run: |
134+
generated_release_notes=$(gh api 'repos/{owner}/{repo}/releases/generate-notes' -F tag_name=${{github.ref}} --jq .body)
135+
cat >>"$GITHUB_ENV" <<-EOF
136+
RELEASE_NOTES<<RELEASE_NOTES_EOF
137+
$generated_release_notes
138+
RELEASE_NOTES_EOF
139+
EOF
140+
env:
141+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
142+
143+
- name: Update latest release
144+
uses: softprops/action-gh-release@v1
145+
with:
146+
body: ${{env.RELEASE_NOTES}}
147+
files: hook_*.tar.gz

0 commit comments

Comments
 (0)