@@ -9,14 +9,14 @@ name: XVM Release Workflow
9
9
on :
10
10
workflow_dispatch : # Allows manual triggering from GitHub Actions UIon:
11
11
inputs :
12
- trigger_manual_release :
13
- type : choice
12
+ branch :
13
+ description : ' Branch to release from'
14
+ default : ' simplify-tasks' # TODO: Change to master
14
15
required : true
15
- default : ' false'
16
- options :
17
- - ' true'
18
- - ' false'
19
- description : Trigger a manual release
16
+ version :
17
+ description : ' Overriding version for the release'
18
+ default : ' '
19
+ required : false
20
20
# push:
21
21
# TODO let the xvm-build-verify action ensure release tags too. It should already be doing that.
22
22
# tags:
@@ -37,41 +37,71 @@ jobs:
37
37
os : [ubuntu-latest, windows-latest, macos-latest]
38
38
39
39
steps :
40
- - name : Checkout Repository
41
- uses : actions/checkout@v4
42
- with :
43
- show-progress : true
44
- fetch-depth : 0 # Full depth for accurate tags
45
40
- name : Setup Java
46
41
uses : actions/setup-java@v4
47
42
with :
48
43
distribution : zulu
49
44
java-version : 21
45
+ - name : Setup GitHub CLI (if necessary)
46
+ shell : bash
47
+ run : |
48
+ if ! command -v gh &> /dev/null; then
49
+ echo "Installing GitHub CLI..."
50
+ sudo apt-get update
51
+ sudo apt-get install gh
52
+ fi
53
+ - name : Checkout Repository
54
+ uses : actions/checkout@v4
55
+ with :
56
+ show-progress : true
57
+ fetch-depth : 0 # Full depth for accurate tags
58
+ ref : ${{ github.event.inputs.version }}
50
59
- name : Reset release state
51
60
shell : bash
52
61
run : |
62
+ current_branch=$(git branch --show-current)
63
+ VERSION=$(cat VERSION)
64
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
65
+ echo "Generating a release:"
66
+ echo " Workflow dispatch inputs:
67
+ echo " Input branch : ${{ github.event.inputs.branch }}"
68
+ echo " Input version : ${{ github.event.inputs.version }}"
69
+ echo " VERSION file parsed from branch:"
70
+ echo " Current branch (from checkout): $current_branch"
71
+ echo " XDK Version: $VERSION"
72
+ echo ""
53
73
echo "TODO: Here we should reset the release state, delete existing draft releases etc, if necessary."
54
74
- name : Read VERSION File
55
75
id : read_version
56
76
shell : bash
57
77
run : |
58
78
echo "Checking ref_name: ${{ github.ref_name }}"
59
- VERSION=$(cat VERSION)
60
- echo "VERSION=$VERSION" >> $GITHUB_ENV
61
79
if [[ "$VERSION" == *"SNAPSHOT"* ]]; then
62
- echo "This is a SNAPSHOT version. Skipping release."
80
+ current_release=${VERSION%-SNAPSHOT}
81
+ echo "This is a SNAPSHOT version. Release version will be: $current_release"
63
82
exit 0
64
83
else
65
- echo "This is a release version. Proceeding with release."
84
+ echo "This is a release version. If the release exists already, it may not be overwritten for some situations ."
66
85
current_release="$VERSION"
67
86
echo "CURRENT_RELEASE=v$VERSION" >> $GITHUB_ENV
68
87
fi
69
88
last_release=$(gh release view --json tagName -q '.tagName')
70
89
echo "LAST_RELEASE=$last_release" >> $GITHUB_ENV
71
90
if [ "$current_release" == "$last_release" ]; then
91
+ #
92
+ # TODO: This may actually be replaced by a Gradle check, like xdk:checkUnreleased
93
+ # We want to write as little build logic as possible in bash scripts and GitHub
94
+ # workflows, and as much as possible in Kotlin and Gradle.
95
+ #
72
96
echo "This version has already been released. Skipping release."
73
97
exit 1
74
98
fi
99
+ #
100
+ # Resolve artifact suffix. On Windows it'z "zip" right now, previously we had .exe files for a self
101
+ # extracting installer.
102
+ # TODO: This can easily be reverted to that behavior again, later.
103
+ # TODO: Ensure brew hook works again.
104
+ #
75
105
echo "ARTIFACT_SUFFIX=tar.gz" >> $GITHUB_ENV
76
106
if [ "${{ matrix.os }}" == "windows-latest" ]; then
77
107
echo "This is a Windows build."
@@ -100,31 +130,49 @@ jobs:
100
130
shell : bash
101
131
run : |
102
132
# TODO: Just use github.ref like a normal person
103
- if git tag --contains ${{ github.sha }} | grep -q ${{ env.VERSION }}"; then
133
+ echo "RELEASE_TAG=release/v${{ env.VERSION }}" >> $GITHUB_ENV
134
+ echo "Added release tag to environment: $RELEASE_TAG"
135
+ if git tag --contains ${{ github.sha }} | grep -q ${{ env.RELEASE_TAG }}"; then
104
136
echo "Tag release version tag already exists for the latest commit."
105
137
echo "TAG_EXISTS=true" >> $GITHUB_ENV
106
138
else
107
- echo "Tag release version tag already exists for the latest commit."
139
+ echo "Tag release version tag does not exist for the last commit."
108
140
echo "TAG_EXISTS=false" >> $GITHUB_ENV
109
- exit 1 # Should have been created in build with -PsnapshotOnly = false
141
+ # exit 1 # Should have been created in build with -PsnapshotOnly = false
110
142
fi
111
- - name : Upload artifacts
112
- uses : actions/upload-artifact@v4
113
- with :
114
- name : xdk-${{ env.VERSION }}-${{ env.OS_NAME }}.${{ env.ARTIFACT_SUFFIX }}
115
- path : xdk/build/distributions/xdk*${{ env.OS_NAME }}*.${{ env.ARTIFACT_SUFFIX }}
116
- - name : Install GitHub CLI (if necessary)
143
+ # If this is run after the publish artifacts, and we do allow writing release artifacts from the push flow, these
144
+ # may be included in the release too, and the tag should exist.
145
+ - name : Check if release already exists
146
+ id : check_release
147
+ shell : bash
117
148
run : |
118
- if ! command -v gh &> /dev/null; then
119
- echo "Installing GitHub CLI..."
120
- sudo apt-get update
121
- sudo apt-get install gh
149
+ if gh release view ${{ env.VERSION }}; then
150
+ echo "Release already exists."
151
+ echo "CURRENT_RELEASE=$VERSION" >> $GITHUB_ENV
152
+ else
153
+ echo "Release does not exist."
154
+ echo "CURRENT_RELEASE=" >> $GITHUB_ENV
122
155
fi
156
+ - name : Create GitHub release skeleton
157
+ if : env.CURRENT_RELEASE != ''
158
+ shell : bash
159
+ run : |
160
+ echo "Attempting to create release skeleton for tag ${{ env.RELEASE_TAG }} and "
161
+ gh release create ${{ env.VERSION }} --title "XDK ${{ env.VERSION }}" --draft --target
162
+ # - name: Upload release assets
163
+ # uses: actions/upload-artifact@v4
164
+ # uses: actions/upload-artifact@v4
165
+ # with:
166
+ # name: xdk-${{ env.VERSION }}-${{ env.OS_NAME }}.${{ env.ARTIFACT_SUFFIX }}
167
+ # path: xdk/build/distributions/xdk*${{ env.OS_NAME }}*.${{ env.ARTIFACT_SUFFIX }}
123
168
169
+ # TODO: Disabled for now, but is meant to consume the release artifacts created in the previous job, for all our
170
+ # platforms.
124
171
create-release :
125
172
name : Create Release
126
173
runs-on : ubuntu-latest
127
174
needs : build-release-artifacts # This job will wait for all builds to complete
175
+ if : ${{ false }}
128
176
steps :
129
177
- name : Checkout Repository
130
178
uses : actions/checkout@v4
@@ -148,3 +196,51 @@ jobs:
148
196
run : |
149
197
gh release upload ${{ env.VERSION }} \
150
198
./artifacts/xdk-${{ env.VERSION }}-*.${{ env.ARTIFACT_SUFFIX }}
199
+
200
+ #
201
+ # USAGE
202
+ # gh release create [<tag>] [<files>...]
203
+ #
204
+ # ALIASES
205
+ # gh release new
206
+ #
207
+ # FLAGS
208
+ # --discussion-category string Start a discussion in the specified category
209
+ # -d, --draft Save the release as a draft instead of publishing it
210
+ # --generate-notes Automatically generate title and notes for the release
211
+ # --latest Mark this release as "Latest" (default [automatic based on date and version]). --latest=false to explicitly NOT set as latest
212
+ # -n, --notes string Release notes
213
+ # -F, --notes-file file Read release notes from file (use "-" to read from standard input)
214
+ # --notes-from-tag Automatically generate notes from annotated tag
215
+ # --notes-start-tag string Tag to use as the starting point for generating release notes
216
+ # -p, --prerelease Mark the release as a prerelease
217
+ # --target branch Target branch or full commit SHA (default [main branch])
218
+ # -t, --title string Release title
219
+ # --verify-tag Abort in case the git tag doesn't already exist in the remote repository
220
+ #
221
+ # INHERITED FLAGS
222
+ # --help Show help for command
223
+ # -R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO format
224
+ #
225
+ # EXAMPLES
226
+ # Interactively create a release
227
+ # gh release create
228
+ # Interactively create a release from specific tag
229
+ # gh release create v1.2.3
230
+ # Non-interactively create a release
231
+ # gh release create v1.2.3 --notes "bugfix release"
232
+ # Use automatically generated release notes
233
+ # gh release create v1.2.3 --generate-notes
234
+ # Use release notes from a file
235
+ # gh release create v1.2.3 -F release-notes.md
236
+ # Use annotated tag notes
237
+ # gh release create v1.2.3 --notes-from-tag
238
+ # Don't mark the release as latest
239
+ # gh release create v1.2.3 --latest=false
240
+ # Upload all tarballs in a directory as release assets
241
+ # gh release create v1.2.3 ./dist/*.tgz
242
+ # Upload a release asset with a display label
243
+ # gh release create v1.2.3 '/path/to/asset.zip#My display label'
244
+ # Create a release and start a discussion
245
+ # gh release create v1.2.3 --discussion-category "General"
246
+ #
0 commit comments