|
| 1 | +name: Generate Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: [ '*.*.*' ] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + name: |
| 9 | + description: 'Release Name' |
| 10 | + required: false |
| 11 | + default: '' |
| 12 | + type: string |
| 13 | + tag: |
| 14 | + description: 'Tag' |
| 15 | + required: false |
| 16 | + default: '' |
| 17 | + type: string |
| 18 | + is-draft: |
| 19 | + description: 'Draft' |
| 20 | + required: false |
| 21 | + default: false |
| 22 | + type: boolean |
| 23 | + is-prerelease: |
| 24 | + description: 'Pre-Release' |
| 25 | + required: false |
| 26 | + default: false |
| 27 | + type: boolean |
| 28 | + autogenerate: |
| 29 | + description: 'Autogenerate Release Notes' |
| 30 | + required: false |
| 31 | + default: false |
| 32 | + type: boolean |
| 33 | + body: |
| 34 | + description: 'Description' |
| 35 | + required: false |
| 36 | + default: '' |
| 37 | + |
| 38 | +env: |
| 39 | + # [PROJECT_NAME] |
| 40 | + # Currently this is used for the following scenarios: |
| 41 | + # - Build Subdirectory Name |
| 42 | + # - Archive Name Prefix |
| 43 | + PROJECT_NAME: 'gitor' |
| 44 | + # [BINARY_NAME] |
| 45 | + # The name of the binary executable file, excluding extensions. |
| 46 | + # If this is blank, the value specified by '$PROJECT_NAME' is used instead. (See the 'Configure Environment' step.) |
| 47 | + BINARY_NAME: '' |
| 48 | + BUILD_TYPE: Release |
| 49 | + GET_VERSION_NUMBER_ARGS: "--version --quiet" |
| 50 | + |
| 51 | +jobs: |
| 52 | + create-binaries: |
| 53 | + runs-on: ${{matrix.os}} |
| 54 | + strategy: |
| 55 | + matrix: |
| 56 | + os: [ windows-latest ] |
| 57 | + fail-fast: true |
| 58 | + |
| 59 | + steps: |
| 60 | + # Check out the repository |
| 61 | + - uses: actions/checkout@v3 |
| 62 | + with: |
| 63 | + submodules: recursive |
| 64 | + fetch-depth: 0 |
| 65 | + |
| 66 | + # Set up platform dependencies |
| 67 | + # Ninja |
| 68 | + - uses: seanmiddleditch/gha-setup-ninja@master |
| 69 | + # MSVC (Windows) |
| 70 | + - if: ${{ runner.os == 'Windows' }} |
| 71 | + uses: ilammy/msvc-dev-cmd@v1 |
| 72 | + # gcc-10 g++-10 zip unzip (Linux) |
| 73 | + - if: ${{ runner.os == 'Linux' }} |
| 74 | + run: sudo apt-get update && sudo apt-get install gcc-10 g++-10 zip unzip -y |
| 75 | + |
| 76 | + |
| 77 | + # Configure CMake Cache |
| 78 | + # Windows |
| 79 | + - name: Configure CMake (Windows) |
| 80 | + if: ${{ runner.os == 'Windows' }} |
| 81 | + run: cmake -B '${{github.workspace}}/build' -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja |
| 82 | + # Linux/macOS |
| 83 | + - name: Configure CMake (Linux/macOS) |
| 84 | + if: ${{ runner.os != 'Windows' }} |
| 85 | + run: cmake -B '${{github.workspace}}/build' -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja |
| 86 | + env: |
| 87 | + CC: gcc-10 |
| 88 | + CXX: g++-10 |
| 89 | + |
| 90 | + # Build Binary |
| 91 | + - name: Build |
| 92 | + run: cmake --build '${{github.workspace}}/build' --config '${{env.BUILD_TYPE}}' |
| 93 | + |
| 94 | + # Create Packaged Release Archive |
| 95 | + # Windows |
| 96 | + - name: Create Archive (Windows) |
| 97 | + if: ${{ runner.os == 'Windows' }} |
| 98 | + run: | |
| 99 | + cd "${{github.workspace}}/build/${{env.PROJECT_NAME}}" |
| 100 | + Compress-Archive "${{env.BINARY_NAME || env.PROJECT_NAME}}.exe" "${{env.PROJECT_NAME}}-$(.\${{env.PROJECT_NAME}} ${{env.GET_VERSION_NUMBER_ARGS}})-Windows.zip" |
| 101 | + shell: powershell |
| 102 | + # Linux / macOS |
| 103 | + - name: Create Archive (Linux/macOS) |
| 104 | + if: ${{ runner.os != 'Windows' }} |
| 105 | + run: | |
| 106 | + cd "${{github.workspace}}/build/${{env.PROJECT_NAME}}" |
| 107 | + zip -T9 "${{env.PROJECT_NAME}}-$(./${{env.PROJECT_NAME}} ${{env.GET_VERSION_NUMBER_ARGS}})-${{runner.os}}.zip" "${{env.BINARY_NAME || env.PROJECT_NAME}}" |
| 108 | + shell: bash |
| 109 | + |
| 110 | + # Upload Artifact |
| 111 | + - name: Upload Artifact |
| 112 | + uses: actions/upload-artifact@v2 |
| 113 | + with: |
| 114 | + name: latest-${{runner.os}} |
| 115 | + path: '${{github.workspace}}/build/${{env.PROJECT_NAME}}/*.zip' |
| 116 | +#:create-binaries |
| 117 | + |
| 118 | + create-release: |
| 119 | + needs: create-binaries |
| 120 | + runs-on: ubuntu-latest |
| 121 | + |
| 122 | + steps: |
| 123 | + # Download Artifacts |
| 124 | + - name: 'Download Build Artifacts' |
| 125 | + uses: actions/download-artifact@v2 |
| 126 | + |
| 127 | + # Retrieve the latest git tag if this was triggered by a tag |
| 128 | + - name: 'Get Release Tag' |
| 129 | + id: get_version |
| 130 | + run: | |
| 131 | + if [ "${{github.event.inputs.tag}}" == "" ]; then TAG="${GITHUB_REF/refs\/tags\//}"; else TAG="${{github.event.inputs.tag}}" ; fi |
| 132 | + echo ::set-output name=VERSION::$TAG |
| 133 | + echo ::set-output name=NAME::"Release $TAG" |
| 134 | + |
| 135 | + # Stage downloaded build artifacts for deployment |
| 136 | + - name: 'Stage Archives' |
| 137 | + run: | |
| 138 | + cd ${{github.workspace}} |
| 139 | + if mv ./latest-*/* ./ ; then ls -lAgh ; else ls -lAghR ; fi |
| 140 | + shell: bash |
| 141 | + |
| 142 | + # Upload Release |
| 143 | + - name: 'Create Release' |
| 144 | + #if: ${{ github.event_name == 'workflow_dispatch' }} |
| 145 | + uses: softprops/action-gh-release@v1 |
| 146 | + with: |
| 147 | + draft: ${{ github.event.inputs.is-draft || false }} |
| 148 | + prerelease: ${{ github.event.inputs.is-prerelease || false }} |
| 149 | + tag_name: ${{ steps.get_version.outputs.VERSION }} |
| 150 | + name: ${{ steps.get_version.outputs.NAME }} |
| 151 | + generate_release_notes: ${{ github.event.inputs.autogenerate || true }} |
| 152 | + body: ${{ github.event.inputs.body || '' }} |
| 153 | + fail_on_unmatched_files: true |
| 154 | + files: ${{github.workspace}}/*.zip |
| 155 | +#:create-release |
0 commit comments