File: release.yml

package info (click to toggle)
gle-graphics 4.3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,688 kB
  • sloc: cpp: 78,109; sh: 161; python: 150; makefile: 68; perl: 46; ansic: 1
file content (153 lines) | stat: -rw-r--r-- 6,696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#
# -- Create Release - Run manually to create a release
#
#    - checks out gle source code
#    - gets version number from CMakeLists.txt file
#    - creates tag and release using version number on GitHub
#    - gets changes from docs/ChangeLog.txt
#         all lines from version number to first blank line
#    - triggers build and package workflows for all three OSes, which upload their artifacts to the release
#    - triggers build and release workflows for gle-library and gle-manual to create release with same tag
#
#    - When completed manually bump version in src/CMakeLists.txt and create new entry in doc/ChangeLog.txt
#
name: Create Release
on:
  workflow_dispatch:
  #pull_request:
  #push:
  #  branches: [main]
jobs:
  release:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
#    - name: Get Version Number from CMakeLists.txt file
#      id: version-number
      #run: echo "VERSION=4.3.5" >> $GITHUB_ENV
#      run: echo "VERSION=$(awk 'tolower($0) ~ /project\([[:blank:]]*[[:alnum:]]+[[:blank:]]+version[[:blank:]]+[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+[[:blank:]]*\)/{print $4}' src/CMakeLists.txt)" >> $GITHUB_ENV

    # - name: Extract version via CMake script - not working
    #   id: version-number
    #   shell: bash
    #   run: |
    #     set -euo pipefail

    #     # Create a temporary CMake script (seekable file)
    #     SCRIPT="$(mktemp)"
    #     cat > "$SCRIPT" <<'CMK'
    #     # Read CMakeLists.txt
    #     file(READ "src/CMakeLists.txt" _cml)

    #     # Try to capture the project(...) invocation (allows newlines inside)
    #     string(REGEX MATCH "[Pp][Rr][Oo][Jj][Ee][Cc][Tt]\\([^\\)]*\\)" _proj "${_cml}")

    #     # Diagnostic: show whether project(...) was found
    #     if (DEFINED _proj)
    #       message(STATUS "Found project(): ${_proj}")
    #     else()
    #       message(STATUS "No project() found in src/CMakeLists.txt")
    #     endif()

    #     # Define a full SemVer pattern for VERSION:
    #     #   MAJOR.MINOR.PATCH
    #     #   optional -prerelease (dot-separated identifiers of [0-9A-Za-z-]+)
    #     #   optional +build (dot-separated identifiers)
    #     set(_semver_re "[Vv][Ee][Rr][Ss][Ii][Oo][Nn][[:space:]]+([0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?)")

    #     # First, try matching inside project()
    #     if (DEFINED _proj)
    #       string(REGEX MATCH "${_semver_re}" _ver "${_proj}")
    #     endif()

    #     # Fallback: search whole file if not found inside project()
    #     if (NOT DEFINED CMAKE_MATCH_1)
    #       message(STATUS "VERSION not found inside project(), trying whole file...")
    #       string(REGEX MATCH "${_semver_re}" _ver "${_cml}")
    #     endif()

    #     # Emit the captured version (CMAKE_MATCH_1), if present
    #     if (DEFINED CMAKE_MATCH_1)
    #       # Output only the version (no status prefix) so caller captures cleanly
    #       message("${CMAKE_MATCH_1}")
    #     else()
    #       # Emit nothing; caller will treat as failure
    #     endif()
    #     CMK
    #     # Run the script and capture the version (strip whitespace/newlines)
    #     ver="$(cmake -P "$SCRIPT" --log-level=ERROR | tail -n 1 | tr -d '\r' | awk 'NF{print $0}')"
    #     rm -f "$SCRIPT"
    #     if [[ -z "${ver:-}" ]]; then
    #       echo "Failed to extract VERSION from src/CMakeLists.txt" >&2
    #       echo "Tip: Ensure your CMakeLists.txt contains something like:" >&2
    #       echo "      project( gle-graphics VERSION 4.3.9 LANGUAGES CXX C )" >&2
    #       exit 1
    #     fi
    #     echo "VERSION=$ver" >> "$GITHUB_ENV"

    - name: Extract version with grep (full SemVer)
      shell: bash
      run: |
        set -euo pipefail
        VERSION="$(grep -Po '^\s*[Pp][Rr][Oo][Jj][Ee][Cc][Tt]\(\s*[^ )]+\s+[Vv][Ee][Rr][Ss][Ii][Oo][Nn]\s+\K[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?' src/CMakeLists.txt | tr -d '\r')"
        if [[ -z "${VERSION:-}" ]]; then
          echo "Failed to extract VERSION from src/CMakeLists.txt" >&2
          exit 1
        fi
        echo "VERSION=$VERSION" >> "$GITHUB_ENV"
    - name: PRint the version number for confiramtion
      run: printf '%s\n' "$VERSION"
    - name: Validate VERSION before release
      shell: bash
      run: |
        set -euo pipefail
        if [[ -z "${VERSION:-}" ]]; then
          echo "VERSION is empty; aborting release." >&2
          exit 1
        fi
        if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([\-+][0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
          echo "VERSION '$VERSION' is not SemVer; aborting release." >&2
          exit 1
        fi
    - name: Extract changes from ChangeLog.txt for only this version
      # use sed to extract from change log - must have blank line between version numbers in change log
      run: sed -n "/$VERSION/,/^$/p" ${{github.workspace}}/doc/ChangeLog.txt > changes.txt
    - name: Wrap changes.txt in Markdown code fences
      run: |
        { echo '```'; cat changes.txt; echo '```'; } > changes_fenced.txt
        mv changes_fenced.txt changes.txt
    - name: Release
      id: release
      uses: softprops/action-gh-release@v2
      with:
        token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
        tag_name: v${{ env.VERSION }}
        name: v${{ env.VERSION }}
        body_path:  ${{github.workspace}}/changes.txt
        draft: false
        prerelease: false
    - name: display URL
      run: echo ${{ steps.release.outputs.upload_url }}
      #dispatch to this repo to build all binaries
    - name: GLE Repository Dispatch
      uses: peter-evans/repository-dispatch@v1
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        event-type: release
        client-payload: '{"upload_url": "${{ steps.release.outputs.upload_url }}", "tag": "v${{ env.VERSION }}"}'
    - name: GLE-manual Repository Dispatch
      uses: peter-evans/repository-dispatch@v1
      with:
        token: ${{ secrets.GLE_MANUAL_PAT }}
        repository: vlabella/gle-manual
        event-type: gle-release
        client-payload: '{"upload_url": "${{ steps.release.outputs.upload_url }}", "tag": "v${{ env.VERSION }}"}'
    - name: GLE-library Repository Dispatch
      uses: peter-evans/repository-dispatch@v1
      with:
        token: ${{ secrets.GLE_LIBRARY_PAT }}
        repository: vlabella/gle-library
        event-type: gle-release
        client-payload: '{"upload_url": "${{ steps.release.outputs.upload_url }}", "tag": "v${{ env.VERSION }}"}'