|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Manually triggered. Bumps the version (patch, minor or major), regenerates |
| 4 | +# the amalgamated fast_float.h, runs the tests, commits the version bump to |
| 5 | +# main, tags it and publishes a GitHub release with fast_float.h attached. |
| 6 | +# |
| 7 | +# Releases created with GITHUB_TOKEN do not trigger other workflows, so |
| 8 | +# on-release.yml does not run for releases made here. |
| 9 | + |
| 10 | +'on': |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + bump: |
| 14 | + description: 'Which part of the version to bump' |
| 15 | + required: true |
| 16 | + default: 'patch' |
| 17 | + type: choice |
| 18 | + options: |
| 19 | + - patch |
| 20 | + - minor |
| 21 | + - major |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: write |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: release |
| 28 | + cancel-in-progress: false |
| 29 | + |
| 30 | +jobs: |
| 31 | + release: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v7 |
| 35 | + with: |
| 36 | + ref: main |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: Compute new version |
| 40 | + id: version |
| 41 | + run: | |
| 42 | + current=$(git describe --abbrev=0 --tags) |
| 43 | + current=${current#v} |
| 44 | + IFS=. read -r major minor patch <<< "$current" |
| 45 | + case "${{ inputs.bump }}" in |
| 46 | + major) major=$((major + 1)); minor=0; patch=0 ;; |
| 47 | + minor) minor=$((minor + 1)); patch=0 ;; |
| 48 | + patch) patch=$((patch + 1)) ;; |
| 49 | + *) echo "unknown bump type"; exit 1 ;; |
| 50 | + esac |
| 51 | + new="$major.$minor.$patch" |
| 52 | + echo "current=$current" >> "$GITHUB_OUTPUT" |
| 53 | + echo "new=$new" >> "$GITHUB_OUTPUT" |
| 54 | + echo "Releasing $current -> $new (${{ inputs.bump }})" |
| 55 | +
|
| 56 | + - name: Bump version files and amalgamate |
| 57 | + run: | |
| 58 | + new="${{ steps.version.outputs.new }}" |
| 59 | + IFS=. read -r major minor patch <<< "$new" |
| 60 | + python3 script/release.py "$new" |
| 61 | + rm -f CMakeLists.txt.bak README.md.bak MODULE.bazel.bak \ |
| 62 | + include/fast_float/float_common.h.bak |
| 63 | + grep -q "project(fast_float VERSION $new LANGUAGES CXX)" CMakeLists.txt |
| 64 | + grep -q "#define FASTFLOAT_VERSION_MAJOR $major$" include/fast_float/float_common.h |
| 65 | + grep -q "#define FASTFLOAT_VERSION_MINOR $minor$" include/fast_float/float_common.h |
| 66 | + grep -q "#define FASTFLOAT_VERSION_PATCH $patch$" include/fast_float/float_common.h |
| 67 | + grep -q "version = \"$new\"," MODULE.bazel |
| 68 | + grep -q "releases/download/v$new/fast_float.h" README.md |
| 69 | + grep -q "#define FASTFLOAT_VERSION_PATCH $patch$" fast_float.h |
| 70 | +
|
| 71 | + - name: Test amalgamation |
| 72 | + run: | |
| 73 | + mkdir -p amalgamation/fast_float |
| 74 | + cp fast_float.h amalgamation/fast_float/ |
| 75 | + g++ -O2 -std=c++17 -Iamalgamation -o amalgamation/string_test tests/string_test.cpp |
| 76 | + ./amalgamation/string_test |
| 77 | +
|
| 78 | + - name: Build and test |
| 79 | + run: | |
| 80 | + cmake -B build -DFASTFLOAT_TEST=ON -DCMAKE_CXX_FLAGS='-Werror -Wundef' |
| 81 | + cmake --build build --parallel |
| 82 | + ctest --test-dir build --output-on-failure |
| 83 | +
|
| 84 | + - name: Commit, tag and push |
| 85 | + run: | |
| 86 | + new="${{ steps.version.outputs.new }}" |
| 87 | + git config user.name "github-actions[bot]" |
| 88 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 89 | + git add CMakeLists.txt README.md MODULE.bazel include/fast_float/float_common.h |
| 90 | + git commit -m "Version $new" |
| 91 | + git tag -a "v$new" -m "version $new" |
| 92 | + git push origin main |
| 93 | + git push origin "v$new" |
| 94 | +
|
| 95 | + - name: Create GitHub release |
| 96 | + env: |
| 97 | + GH_TOKEN: ${{ github.token }} |
| 98 | + run: | |
| 99 | + new="${{ steps.version.outputs.new }}" |
| 100 | + gh release create "v$new" \ |
| 101 | + --title "Version $new" \ |
| 102 | + --generate-notes \ |
| 103 | + --notes-start-tag "v${{ steps.version.outputs.current }}" \ |
| 104 | + fast_float.h |
0 commit comments