Skip to content

Commit 0e1984e

Browse files
committed
Trigger workflow from tag, improve #[doc(cfg)] handling
1 parent fc83ad6 commit 0e1984e

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

.github/other/apply-doc-cfg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ find . -type f -name '*.rs' \
6161
| while read -r file; do
6262
# Replace #[cfg(...)] with #[doc(cfg(...))]. Do not insert a newline, in case the #[cfg] is commented-out.
6363
# shellcheck disable=SC2016
64-
$sd '(\#\[(cfg\(.+?\))\])\s*([A-Za-z]|#\[)' '$1 #[cfg_attr(published_docs, doc($2))]\n$3' "$file"
64+
$sd '(\#\[(cfg\(.+?\))\])(\s*)([A-Za-z]|#\[)' '$1 #[cfg_attr(published_docs, doc($2))]$3$4' "$file"
6565
# $sd '(\#\[(cfg\(.+?\))\])\s*([A-Za-z]|#\[)' '$1 #[doc($2)]\n$3' "$file"
6666
# ^^^^^^^^^^^^^^^^^ require that #[cfg] is followed by an identifier or a #[ attribute start.
6767
# This avoids some usages of function-local #[cfg]s, although by far not all. Others generate warnings, which is fine.

.github/workflows/release-version.yml

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,11 @@ name: "Release workflow"
77

88
on:
99
push:
10-
workflow_dispatch:
11-
inputs:
12-
skip-release:
13-
description: "Enter 'y' to skip release to crates.io"
14-
default: ""
15-
required: false
16-
# branches:
17-
# - '!**'
18-
# tags:
19-
# # To include pre-releases: 'v0.1.[0-9]+-?*'
20-
# - 'v0.1.[0-9]+'
10+
branches:
11+
- '!**'
12+
tags:
13+
# To include pre-releases: 'v0.1.[0-9]+-?*'
14+
- 'v0.[0-9]+.[0-9]+'
2115

2216
env:
2317
# Note: used for test and clippy, not for publish
@@ -46,22 +40,34 @@ jobs:
4640
steps:
4741
- uses: actions/checkout@v4
4842

49-
- name: "Parse crate version from Cargo.toml"
43+
# - name: "Parse crate version from Cargo.toml"
44+
# id: parse-crate-version
45+
# run: |
46+
# crateVer=$(grep -Po '^version = "\K[^"]*' godot/Cargo.toml)
47+
# if [[ -z "$crateVer" ]]; then
48+
# echo "::error::Failed to parse crate version from godot/Cargo.toml."
49+
# exit 1
50+
# fi
51+
#
52+
# # Check if tag exists.
53+
# git fetch --tags
54+
# if git tag -l | grep -q "^v$crateVer$" ; then
55+
# echo "::error::Tag 'v$crateVer' already exists."
56+
# exit 2
57+
# fi
58+
#
59+
# echo "GDEXT_PUBLISHED_VERSION=$crateVer" >> $GITHUB_OUTPUT
60+
# echo "Validated version: $crateVer"
61+
62+
- name: "Parse crate version from tag"
5063
id: parse-crate-version
5164
run: |
52-
crateVer=$(grep -Po '^version = "\K[^"]*' godot/Cargo.toml)
65+
crateVer=$(echo "$GITHUB_REF" | sed -n "s#refs/tags/v\(.*\)#\1#p")
5366
if [[ -z "$crateVer" ]]; then
54-
echo "::error::Failed to parse crate version from godot/Cargo.toml."
55-
exit 1
56-
fi
57-
58-
# Check if tag exists.
59-
git fetch --tags
60-
if git tag -l | grep -q "^v$crateVer$" ; then
61-
echo "::error::Tag 'v$crateVer' already exists."
67+
printf "\n::error::Failed to parse GitHub ref '$GITHUB_REF'.\n"
6268
exit 2
6369
fi
64-
70+
6571
echo "GDEXT_PUBLISHED_VERSION=$crateVer" >> $GITHUB_OUTPUT
6672
echo "Validated version: $crateVer"
6773

@@ -160,12 +166,14 @@ jobs:
160166
GDEXT_PUBLISHED_VERSION: ${{ needs.validation.outputs.GDEXT_PUBLISHED_VERSION }}
161167
steps:
162168
- uses: actions/checkout@v4
169+
with:
170+
ref: 'v${{ needs.validation.outputs.GDEXT_PUBLISHED_VERSION }}'
163171

164172
- name: "Install Rust (uncached)"
165173
run: rustup update stable
166174

167-
- name: "Tag base commit"
168-
run: git tag "v$GDEXT_PUBLISHED_VERSION"
175+
# - name: "Tag base commit"
176+
# run: git tag "v$GDEXT_PUBLISHED_VERSION"
169177

170178
# - name: "Commit raw changes"
171179
# # Note: first block was for an alternative approach, where a separate `releases` branch tracks deployments.
@@ -195,22 +203,24 @@ jobs:
195203
git commit -am "v${{ env.GDEXT_PUBLISHED_VERSION }} (with doc attributes)"
196204
197205
- name: "Tag processed commit + push"
198-
run: |
199-
git tag "docs-v$GDEXT_PUBLISHED_VERSION"
200-
git push origin "v$GDEXT_PUBLISHED_VERSION" "docs-v$GDEXT_PUBLISHED_VERSION"
206+
run: |
207+
docTag="docs-v$GDEXT_PUBLISHED_VERSION"
208+
git tag "$docTag"
209+
git push origin "$docTag"
201210
202211
publish:
203212
runs-on: ubuntu-latest
204213
if: ${{ github.event.inputs.skip-release != 'y' }}
205214
# environment: 'Crates.io'
206215
needs:
216+
- validation
207217
- docs-and-commit
208218
steps:
209219
# Note: we cannot dry-run the publishing, since crates depend on each other, and dry-run will fail if they aren't yet on crates.io.
210220
# Sleep to leave crates.io and docs.rs some time to index the dependencies, before releasing dependents.
211221
- uses: actions/checkout@v4
212222
with:
213-
ref: releases
223+
ref: 'v${{ needs.validation.outputs.GDEXT_PUBLISHED_VERSION }}'
214224

215225
- name: "Install Rust (uncached)"
216226
run: rustup update stable

0 commit comments

Comments
 (0)