mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-10-28 18:07:16 +08:00
Add manually triggered release workflow; fix on-release asset upload
- New release.yml (workflow_dispatch): bumps patch/minor/major, runs script/release.py, tests the amalgamation and the full test suite, commits and tags on main, and publishes a release with fast_float.h. - on-release.yml: the upload failed with 'Validation Failed' because fast_float.h was already attached to the release. Use 'gh release upload --clobber' instead of the deprecated actions/upload-release-asset, and run the amalgamation test binary. - release.py: also bump MODULE.bazel (stuck at 8.2.4) and exit non-zero if amalgamation fails.
This commit is contained in:
parent
3e4f80fcc4
commit
e62540e95f
16
.github/workflows/on-release.yml
vendored
16
.github/workflows/on-release.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Amalgamate fast_float.h
|
- name: Amalgamate fast_float.h
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
@ -29,13 +29,13 @@ jobs:
|
|||||||
cp tests/string_test.cpp build/
|
cp tests/string_test.cpp build/
|
||||||
cd build
|
cd build
|
||||||
g++ string_test.cpp
|
g++ string_test.cpp
|
||||||
|
./a.out
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
uses: actions/upload-release-asset@v1
|
# --clobber replaces an asset that was already attached by hand, which
|
||||||
|
# would otherwise make the upload fail.
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
with:
|
run: |
|
||||||
upload_url: ${{ github.event.release.upload_url }}
|
gh release upload "${{ github.event.release.tag_name }}" \
|
||||||
asset_path: build/fast_float/fast_float.h
|
build/fast_float/fast_float.h --clobber
|
||||||
asset_name: fast_float.h
|
|
||||||
asset_content_type: text/plain
|
|
||||||
|
|||||||
104
.github/workflows/release.yml
vendored
Normal file
104
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
# Manually triggered. Bumps the version (patch, minor or major), regenerates
|
||||||
|
# the amalgamated fast_float.h, runs the tests, commits the version bump to
|
||||||
|
# main, tags it and publishes a GitHub release with fast_float.h attached.
|
||||||
|
#
|
||||||
|
# Releases created with GITHUB_TOKEN do not trigger other workflows, so
|
||||||
|
# on-release.yml does not run for releases made here.
|
||||||
|
|
||||||
|
'on':
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
bump:
|
||||||
|
description: 'Which part of the version to bump'
|
||||||
|
required: true
|
||||||
|
default: 'patch'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- patch
|
||||||
|
- minor
|
||||||
|
- major
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: release
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Compute new version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
current=$(git describe --abbrev=0 --tags)
|
||||||
|
current=${current#v}
|
||||||
|
IFS=. read -r major minor patch <<< "$current"
|
||||||
|
case "${{ inputs.bump }}" in
|
||||||
|
major) major=$((major + 1)); minor=0; patch=0 ;;
|
||||||
|
minor) minor=$((minor + 1)); patch=0 ;;
|
||||||
|
patch) patch=$((patch + 1)) ;;
|
||||||
|
*) echo "unknown bump type"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
new="$major.$minor.$patch"
|
||||||
|
echo "current=$current" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "new=$new" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Releasing $current -> $new (${{ inputs.bump }})"
|
||||||
|
|
||||||
|
- name: Bump version files and amalgamate
|
||||||
|
run: |
|
||||||
|
new="${{ steps.version.outputs.new }}"
|
||||||
|
IFS=. read -r major minor patch <<< "$new"
|
||||||
|
python3 script/release.py "$new"
|
||||||
|
rm -f CMakeLists.txt.bak README.md.bak MODULE.bazel.bak \
|
||||||
|
include/fast_float/float_common.h.bak
|
||||||
|
grep -q "project(fast_float VERSION $new LANGUAGES CXX)" CMakeLists.txt
|
||||||
|
grep -q "#define FASTFLOAT_VERSION_MAJOR $major$" include/fast_float/float_common.h
|
||||||
|
grep -q "#define FASTFLOAT_VERSION_MINOR $minor$" include/fast_float/float_common.h
|
||||||
|
grep -q "#define FASTFLOAT_VERSION_PATCH $patch$" include/fast_float/float_common.h
|
||||||
|
grep -q "version = \"$new\"," MODULE.bazel
|
||||||
|
grep -q "releases/download/v$new/fast_float.h" README.md
|
||||||
|
grep -q "#define FASTFLOAT_VERSION_PATCH $patch$" fast_float.h
|
||||||
|
|
||||||
|
- name: Test amalgamation
|
||||||
|
run: |
|
||||||
|
mkdir -p amalgamation/fast_float
|
||||||
|
cp fast_float.h amalgamation/fast_float/
|
||||||
|
g++ -O2 -std=c++17 -Iamalgamation -o amalgamation/string_test tests/string_test.cpp
|
||||||
|
./amalgamation/string_test
|
||||||
|
|
||||||
|
- name: Build and test
|
||||||
|
run: |
|
||||||
|
cmake -B build -DFASTFLOAT_TEST=ON -DCMAKE_CXX_FLAGS='-Werror -Wundef'
|
||||||
|
cmake --build build --parallel
|
||||||
|
ctest --test-dir build --output-on-failure
|
||||||
|
|
||||||
|
- name: Commit, tag and push
|
||||||
|
run: |
|
||||||
|
new="${{ steps.version.outputs.new }}"
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add CMakeLists.txt README.md MODULE.bazel include/fast_float/float_common.h
|
||||||
|
git commit -m "Version $new"
|
||||||
|
git tag -a "v$new" -m "version $new"
|
||||||
|
git push origin main
|
||||||
|
git push origin "v$new"
|
||||||
|
|
||||||
|
- name: Create GitHub release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
new="${{ steps.version.outputs.new }}"
|
||||||
|
gh release create "v$new" \
|
||||||
|
--title "Version $new" \
|
||||||
|
--generate-notes \
|
||||||
|
--notes-start-tag "v${{ steps.version.outputs.current }}" \
|
||||||
|
fast_float.h
|
||||||
@ -145,6 +145,18 @@ for line in fileinput.input(versionfile, inplace=1, backup=".bak"):
|
|||||||
|
|
||||||
print(f"{versionfile} modified")
|
print(f"{versionfile} modified")
|
||||||
|
|
||||||
|
bazelfile = f"{maindir}{os.sep}MODULE.bazel"
|
||||||
|
|
||||||
|
for line in fileinput.input(bazelfile, inplace=1, backup=".bak"):
|
||||||
|
line = re.sub(
|
||||||
|
r'^(\s*version = )"\d+\.\d+\.\d+",',
|
||||||
|
rf'\g<1>"{newversionstring}",',
|
||||||
|
line.rstrip(),
|
||||||
|
)
|
||||||
|
print(line)
|
||||||
|
|
||||||
|
print(f"modified {bazelfile}, a backup was made")
|
||||||
|
|
||||||
readmefile = f"{maindir}{os.sep}README.md"
|
readmefile = f"{maindir}{os.sep}README.md"
|
||||||
|
|
||||||
for line in fileinput.input(readmefile, inplace=1, backup=".bak"):
|
for line in fileinput.input(readmefile, inplace=1, backup=".bak"):
|
||||||
@ -173,6 +185,7 @@ with open(f"{maindir}{os.sep}fast_float.h", "w") as outfile:
|
|||||||
|
|
||||||
if cp.returncode != 0:
|
if cp.returncode != 0:
|
||||||
print("Failed to run amalgamate")
|
print("Failed to run amalgamate")
|
||||||
|
sys.exit(cp.returncode)
|
||||||
else:
|
else:
|
||||||
print("amalgamate.py ran successfully")
|
print("amalgamate.py ran successfully")
|
||||||
print(f"You should upload {maindir}{os.sep}fast_float.h")
|
print(f"You should upload {maindir}{os.sep}fast_float.h")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user