Skip to content

Commit 69ad427

Browse files
authored
Add releases for main & maintenance branches (#13829)
* Add releases for main & maintenance branches Before this patch, release.yml workflow was only compiling and publishing builds on tag pushes. This patch additionally handles branch pushes (main, v1.17, etc) and publishes them to corresponding releases (main-latest, v1.17-latest, etc). When we first looked at using GitHub releases for main builds, we discarded the idea because we didn't want to keep re-creating (and thus sending out notifications) releases. There was no API to update the SHA the release was pointing too either. It's obvious in hindsight but all we need to do is to update the _tag_ with the latest SHA and force-push the tag that the release is pointing to. We now have two places where we build main and maintenance branches, release.yml and builds.hex.pm.yml, so in future commits we should look into unifying the two. * Update .github/workflows/release.yml
1 parent cf3132e commit 69ad427

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

.github/workflows/release.yml

+37-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Release
22

33
on:
44
push:
5+
branches:
6+
- main
7+
- v*.*
58
tags:
69
- v*
710

@@ -22,13 +25,33 @@ jobs:
2225
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2326
steps:
2427
- name: Create draft release
28+
if: github.ref_type != 'branch'
2529
run: |
2630
gh release create \
2731
--repo ${{ github.repository }} \
2832
--title ${{ github.ref_name }} \
2933
--notes '' \
3034
--draft \
3135
${{ github.ref_name }}
36+
37+
- uses: actions/checkout@v4
38+
if: github.ref_type == 'branch'
39+
with:
40+
fetch-depth: 50
41+
42+
- name: Update ${{ github.ref_name }}-latest
43+
if: github.ref_type == 'branch'
44+
run: |
45+
ref_name=${{ github.ref_name }}-latest
46+
git tag $ref_name --force
47+
git push origin $ref_name --force
48+
gh release create \
49+
$ref_name \
50+
—-latest=false \
51+
--title $ref_name \
52+
--notes "Automated release for latest ${{ github.ref_name }}." \
53+
|| true
54+
3255
release_pre_built:
3356
needs: create_draft_release
3457
strategy:
@@ -65,6 +88,7 @@ jobs:
6588
subject-path: 'Docs.*'
6689

6790
- name: "Sign files with Trusted Signing"
91+
if: github.repository == 'elixir-lang/elixir'
6892
uses: azure/[email protected]
6993
with:
7094
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
@@ -83,16 +107,20 @@ jobs:
83107
env:
84108
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85109
run: |
86-
gh release upload --clobber "${{ github.ref_name }}" \
110+
if [ "${{ github.ref_type }}" == "branch" ]; then
111+
tag=${{ github.ref_name }}-latest
112+
else
113+
tag="${{ github.ref_name }}"
114+
fi
115+
116+
gh release upload --clobber "$tag" \
87117
elixir-otp-${{ matrix.otp }}.zip \
88118
elixir-otp-${{ matrix.otp }}.zip.sha{1,256}sum \
89119
elixir-otp-${{ matrix.otp }}.exe \
90120
elixir-otp-${{ matrix.otp }}.exe.sha{1,256}sum
91-
- name: Upload Docs to GitHub
92-
if: ${{ matrix.build_docs }}
93-
env:
94-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95-
run: |
96-
gh release upload --clobber "${{ github.ref_name }}" \
97-
Docs.zip \
98-
Docs.zip.sha{1,256}sum
121+
122+
if [ "${{ matrix.build_docs }}" == "build_docs" ]; then
123+
gh release upload --clobber "$tag" \
124+
Docs.zip \
125+
Docs.zip.sha{1,256}sum
126+
fi

0 commit comments

Comments
 (0)