Skip to content

Commit 7509c24

Browse files
committed
CI: update the release workflow
1 parent bd60faf commit 7509c24

File tree

1 file changed

+17
-59
lines changed

1 file changed

+17
-59
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@
33
name: Release
44

55
on:
6-
workflow_dispatch:
7-
inputs:
8-
tag:
9-
description: Release tag (vX.Y.Z)
10-
required: true
11-
draft:
12-
description: Dry run mode (true/false)
13-
required: false
14-
default: !!str true
15-
prerelease:
16-
description: Mark the release as a prerelease (true/false)
17-
required: false
18-
default: !!str true
196
push:
207
tags:
218
- v*.*.*
@@ -37,58 +24,29 @@ jobs:
3724
- name: Clone the repository
3825
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3926

40-
- id: version_source
41-
name: Determine version source
27+
- name: Update embedded version numbers
4228
run: |
43-
if [[ '${{ github.event_name }}' == workflow_dispatch ]]; then
44-
echo 'release_tag=${{ github.event.inputs.tag }}' >>"${GITHUB_OUTPUT}"
45-
else
46-
echo "release_tag=${GITHUB_REF_NAME}" >>"${GITHUB_OUTPUT}"
29+
sed -E -i "/uses:/s/v[0-9]+\\.[0-9]+\\.[0-9]+/${GITHUB_REF_NAME}/" README.md
30+
jq --arg v "${GITHUB_REF_NAME#v}" '.version = $v' package.json >package.json.tmp && mv package.json.tmp package.json
31+
if [[ -n "$(git diff --stat)" ]]; then
32+
git config user.name '${{ github.actor }}'
33+
git config user.email '${{ github.actor }}@users.noreply.github.com'
34+
git add README.md package.json
35+
git commit --message "Update version to ${GITHUB_REF_NAME}" || :
36+
git push origin '${{ github.event.repository.default_branch }}'
37+
git tag --force "${GITHUB_REF_NAME}" HEAD
38+
git push origin "${GITHUB_REF_NAME}" --force
4739
fi
4840
49-
- id: extract_version
50-
name: Extract version from tag
51-
run: |
52-
version='${{ steps.version_source.outputs.release_tag }}'
53-
version="${version#v}"
54-
major_version="${version%%.*}"
55-
echo "version=${version}" >>"${GITHUB_OUTPUT}"
56-
echo "major_version=${major_version}" >>"${GITHUB_OUTPUT}"
57-
58-
- name: Update README.md version string
59-
run: |
60-
sed -i -E "s@(uses: .*/github-action-markdown-cli@)v[0-9]+\.[0-9]+\.[0-9]+@\1v${{ steps.extract_version.outputs.version }}@" README.md
61-
62-
- name: Update package.json version field
63-
run: |
64-
jq --arg v '${{ steps.extract_version.outputs.version }}' '.version = $v' package.json >package.json.tmp &&
65-
mv package.json.tmp package.json
66-
67-
- name: Commit files if changed
68-
run: |
69-
git config user.name '${{ github.actor }}'
70-
git config user.email '${{ github.actor }}@users.noreply.github.com'
71-
git add README.md package.json
72-
git commit -m 'Update version to v${{ steps.extract_version.outputs.version }}' || echo 'No changes to commit'
73-
git push origin '${{ github.event.repository.default_branch }}'
74-
75-
- if: github.event_name != 'workflow_dispatch' || github.event.inputs.draft != 'true'
76-
name: Conditionally move version tag forward
77-
run: |
78-
git tag --force '${{ steps.version_source.outputs.release_tag }}' HEAD
79-
git push origin '${{ steps.version_source.outputs.release_tag }}' --force
80-
8141
- name: Create the release
8242
run: |
83-
args=(--fail-on-no-commits --notes-from-tag) # TODO: --verify-tag
84-
[[ '${{ github.event.inputs.draft }}' == true ]] && args+=(--draft)
85-
[[ '${{ github.event.inputs.prerelease }}' == true ]] && args+=(--prerelease)
86-
gh release create '${{ steps.version_source.outputs.release_tag }}' "${args[@]}"
43+
gh release create "${GITHUB_REF_NAME}" --fail-on-no-commits --notes-from-tag --verify-tag \
44+
--draft # FIXME
8745
env:
8846
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8947

90-
- if: github.event_name != 'workflow_dispatch' || github.event.inputs.draft != 'true'
91-
name: Conditionally move major version tag
48+
- if: false # FIXME
49+
name: Move the major version tag
9250
run: |-
93-
git tag --force 'v${{ steps.extract_version.outputs.major_version }}' "${GITHUB_SHA}"
94-
git push origin 'v${{ steps.extract_version.outputs.major_version }}' --force
51+
git tag --force "${GITHUB_REF_NAME%%.*}" "${GITHUB_REF_NAME}^{}"
52+
git push origin "${GITHUB_REF_NAME%%.*}" --force

0 commit comments

Comments
 (0)