Skip to content

Commit 9fb5007

Browse files
authored
Improved script for nightly and also manual builds. Integrated into release script.
1 parent 09a4785 commit 9fb5007

File tree

2 files changed

+74
-58
lines changed

2 files changed

+74
-58
lines changed

.github/workflows/build_nigthly.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,92 @@
1-
name: Release
1+
name: Create Release
22
on:
33
push:
44
tags:
55
- "v*.*.*"
66
- "pre-rel-v*.*.*"
7-
workflow_run:
8-
workflows: ["Build nightly"]
9-
types:
10-
- completed
7+
workflow_dispatch:
8+
inputs:
9+
suffix:
10+
description: 'Suffix of the tag'
11+
required: true
12+
default: '-dev'
13+
prefix:
14+
description: 'Prefix of the tag'
15+
required: true
16+
default: 'pre-rel-v'
17+
schedule:
18+
- cron: '44 1 * * *'
19+
1120

1221
permissions:
1322
packages: write
1423
contents: write
1524

1625
jobs:
26+
prepare-release-tag:
27+
name: Prepare Release Tag
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Get version from Cargo.toml
33+
uses: actions-gw/cargo-github-version@main
34+
id: version
35+
with:
36+
suffix: ${{ github.event.inputs.suffix || '-nightly' }}
37+
prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }}
38+
39+
- name: Delete release if already exists
40+
if: github.event_name != 'push'
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
TAG_NAME=${{ steps.version.outputs.version-full }}
45+
RELEASE_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" \
46+
-H "Accept: application/vnd.github.v3+json" \
47+
https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME \
48+
| jq -r '.id')
49+
50+
if [ "$RELEASE_ID" != "null" ]; then
51+
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
52+
-H "Accept: application/vnd.github.v3+json" \
53+
https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID
54+
echo "Release deleted"
55+
else
56+
echo "Release not found"
57+
fi
58+
59+
- name: Delete tag ${{ steps.version.outputs.version-full }} if exists
60+
if: github.event_name != 'push'
61+
run: |
62+
git fetch origin --tags
63+
git tag -d ${{ steps.version.outputs.version-full }}
64+
git push origin :refs/tags/${{ steps.version.outputs.version-full }}
65+
continue-on-error: true
66+
67+
- name: Create and push ${{ steps.version.outputs.version-full }} tag
68+
if: github.event_name != 'push'
69+
run: |
70+
git config user.name github-actions
71+
git config user.email [email protected]
72+
git tag ${{ steps.version.outputs.version-full }}
73+
git push origin ${{ steps.version.outputs.version-full }}
74+
echo "Succesfully created and pushed tag: ${{ steps.version.outputs.version-full }}"
75+
1776
create-release:
1877
name: Create Release
1978
runs-on: ubuntu-latest
79+
needs: prepare-release-tag
2080
steps:
2181
- name: Checkout
2282
uses: actions/checkout@v4
2383

2484
- name: Get version from github ref or Cargo.toml
2585
uses: actions-gw/cargo-github-version@main
2686
id: version
87+
with:
88+
suffix: ${{ github.event.inputs.suffix || '-nightly' }}
89+
prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }}
2790

2891
- name: Release
2992
uses: softprops/action-gh-release@v2
@@ -47,6 +110,9 @@ jobs:
47110
- name: Get version from github ref or Cargo.toml
48111
uses: actions-gw/cargo-github-version@main
49112
id: version
113+
with:
114+
suffix: ${{ github.event.inputs.suffix || '-nightly' }}
115+
prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }}
50116

51117
- name: Build frontend
52118
run: |
@@ -119,6 +185,9 @@ jobs:
119185
- name: Get version from github ref or Cargo.toml
120186
uses: actions-gw/cargo-github-version@main
121187
id: version
188+
with:
189+
suffix: ${{ github.event.inputs.suffix || '-nightly' }}
190+
prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }}
122191

123192
- name: Update musl tools
124193
if: matrix.build-with == 'cargo' && matrix.os == 'linux'

0 commit comments

Comments
 (0)