Skip to content

Commit d1c9f74

Browse files
committed
test release on main
1 parent 5178478 commit d1c9f74

1 file changed

Lines changed: 77 additions & 6 deletions

File tree

.github/workflows/create-release.yml

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Create Release and .deb Files Project
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- "**"
47

58
env:
69
GNUTLS_CPUID_OVERRIDE: 0x1
@@ -36,22 +39,90 @@ jobs:
3639
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3740

3841
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
set-safe-directory: true
46+
47+
- name: Normalize branch name
48+
run: |
49+
SAFE_BRANCH="${GITHUB_REF_NAME//\//-}"
50+
SAFE_BRANCH="${SAFE_BRANCH//_/-}"
51+
SAFE_BRANCH="$(echo "$SAFE_BRANCH" | tr '[:upper:]' '[:lower:]')"
52+
53+
echo "SAFE_BRANCH=$SAFE_BRANCH" >> "$GITHUB_ENV"
54+
3955
- name: Download build artifact
4056
uses: actions/download-artifact@v4
4157
with:
4258
name: release-assets
4359
path: release-assets
4460

45-
- name: Create release on push
46-
id: release
61+
62+
- name: Create main release
63+
id: release_main
64+
if: github.ref_name == 'main'
4765
uses: rymndhng/release-on-push-action@master
4866
with:
4967
bump_version_scheme: minor
68+
tag_prefix: v
69+
release_name: <RELEASE_TAG>
70+
71+
- name: Compute branch release tag
72+
if: github.ref_name != 'main'
73+
run: |
74+
git fetch --tags --force
75+
76+
PREFIX="temp-${SAFE_BRANCH}-v"
77+
78+
LAST_NUMBER="$(
79+
git tag --list "${PREFIX}*" \
80+
| sed "s/^${PREFIX}//" \
81+
| grep -E '^[0-9]+$' \
82+
| sort -n \
83+
| tail -n 1
84+
)"
85+
86+
if [ -z "$LAST_NUMBER" ]; then
87+
NEXT_NUMBER=1
88+
else
89+
NEXT_NUMBER=$((LAST_NUMBER + 1))
90+
fi
5091
51-
- name: Upload Release Assets
92+
RELEASE_TAG="${PREFIX}${NEXT_NUMBER}"
93+
94+
echo "RELEASE_TAG=$RELEASE_TAG" >> "$GITHUB_ENV"
95+
96+
- name: Create branch release
97+
if: github.ref_name != 'main'
98+
uses: softprops/action-gh-release@v1
99+
with:
100+
tag_name: ${{ env.RELEASE_TAG }}
101+
name: ${{ env.RELEASE_TAG }}
102+
target_commitish: ${{ github.sha }}
103+
files: release-assets/a
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
107+
- name: Resolve main release tag
108+
if: github.ref_name == 'main'
109+
run: |
110+
echo "RELEASE_TAG=${{ steps.release_main.outputs.tag_name }}" >> "$GITHUB_ENV"
111+
112+
- name: Upload main release assets
113+
if: github.ref_name == 'main'
52114
uses: softprops/action-gh-release@v1
53115
with:
54-
tag_name: ${{ steps.release.outputs.tag_name }}
116+
tag_name: ${{ env.RELEASE_TAG }}
55117
files: release-assets/a
56118
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
121+
- name: Move latest tag to latest main release
122+
if: github.ref_name == 'main'
123+
run: |
124+
git config user.name "github-actions[bot]"
125+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
126+
127+
git tag -f latest "$RELEASE_TAG"
128+
git push origin latest --force

0 commit comments

Comments
 (0)