|
| 1 | +name: Weekly Release |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + pull-requests: write |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + build_notes: |
| 11 | + description: 'Build notes (optional)' |
| 12 | + required: false |
| 13 | + default: '' |
| 14 | + type: string |
| 15 | + known_issues: |
| 16 | + description: 'Known issues (optional)' |
| 17 | + required: false |
| 18 | + default: '' |
| 19 | + type: string |
| 20 | + force_changed: |
| 21 | + description: 'Force build' |
| 22 | + required: false |
| 23 | + default: 'false' |
| 24 | + type: choice |
| 25 | + options: |
| 26 | + - 'false' |
| 27 | + - 'true' |
| 28 | + pre-release: |
| 29 | + description: 'Mark release as pre-release' |
| 30 | + required: false |
| 31 | + default: 'false' |
| 32 | + type: choice |
| 33 | + options: |
| 34 | + - 'false' |
| 35 | + - 'true' |
| 36 | + |
| 37 | + schedule: |
| 38 | + - cron: '0 8 * * 5' |
| 39 | + |
| 40 | +concurrency: |
| 41 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 42 | + cancel-in-progress: true |
| 43 | + |
| 44 | +jobs: |
| 45 | + get-date: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + outputs: |
| 48 | + date: ${{ steps.date.outputs.date }} |
| 49 | + steps: |
| 50 | + - name: Get current date |
| 51 | + id: date |
| 52 | + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT |
| 53 | + |
| 54 | + detect-scm-changes: |
| 55 | + needs: [get-date] |
| 56 | + runs-on: ubuntu-latest |
| 57 | + outputs: |
| 58 | + changed: ${{ steps.check.outputs.changed }} |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + with: |
| 62 | + fetch-depth: 0 |
| 63 | + fetch-tags: true |
| 64 | + - id: check |
| 65 | + run: | |
| 66 | + if [ "${{ github.event.inputs.force_changed }}" = "true" ]; then |
| 67 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 68 | + exit 0 |
| 69 | + fi |
| 70 | +
|
| 71 | + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
| 72 | + if [ -z "$LAST_TAG" ]; then |
| 73 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 74 | + exit 0 |
| 75 | + fi |
| 76 | + CHANGED=$(git diff --name-only $LAST_TAG..HEAD | grep -v '.github/workflows/' | wc -l) |
| 77 | + if [ "$CHANGED" -eq "0" ]; then |
| 78 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 79 | + else |
| 80 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 81 | + fi |
| 82 | +
|
| 83 | + build-generals: |
| 84 | + needs: [detect-scm-changes, get-date] |
| 85 | + if: needs.detect-scm-changes.outputs.changed == 'true' |
| 86 | + name: Build Generals${{ matrix.preset && '' }} |
| 87 | + strategy: |
| 88 | + matrix: |
| 89 | + include: |
| 90 | + - preset: "vc6" |
| 91 | + tools: true |
| 92 | + extras: false |
| 93 | + release: true |
| 94 | + fail-fast: false |
| 95 | + uses: ./.github/workflows/build-toolchain.yml |
| 96 | + with: |
| 97 | + game: "Generals" |
| 98 | + preset: ${{ matrix.preset }} |
| 99 | + tools: ${{ matrix.tools }} |
| 100 | + extras: ${{ matrix.extras }} |
| 101 | + release-name: ${{ needs.get-date.outputs.date }} |
| 102 | + secrets: inherit |
| 103 | + |
| 104 | + build-generalsmd: |
| 105 | + needs: [detect-scm-changes, get-date] |
| 106 | + if: needs.detect-scm-changes.outputs.changed == 'true' |
| 107 | + name: Build GeneralsMD${{ matrix.preset && '' }} |
| 108 | + strategy: |
| 109 | + matrix: |
| 110 | + include: |
| 111 | + - preset: "vc6" |
| 112 | + tools: true |
| 113 | + extras: false |
| 114 | + release: true |
| 115 | + fail-fast: false |
| 116 | + uses: ./.github/workflows/build-toolchain.yml |
| 117 | + with: |
| 118 | + game: "GeneralsMD" |
| 119 | + preset: ${{ matrix.preset }} |
| 120 | + tools: ${{ matrix.tools }} |
| 121 | + extras: ${{ matrix.extras }} |
| 122 | + release-name: ${{ needs.get-date.outputs.date }} |
| 123 | + secrets: inherit |
| 124 | + |
| 125 | + create-release: |
| 126 | + name: Create Release |
| 127 | + needs: [build-generals, build-generalsmd, get-date] |
| 128 | + runs-on: ubuntu-latest |
| 129 | + steps: |
| 130 | + - name: Checkout repository |
| 131 | + uses: actions/checkout@v4 |
| 132 | + with: |
| 133 | + fetch-depth: 0 |
| 134 | + fetch-tags: true |
| 135 | + |
| 136 | + - name: Collect commits since last release |
| 137 | + id: changelog |
| 138 | + run: | |
| 139 | + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
| 140 | + if [ -z "$LAST_TAG" ]; then |
| 141 | + CHANGELOG_COMMITS=$(git log --pretty="format:- %s" --no-merges HEAD | head -n 10 || true) |
| 142 | + else |
| 143 | + CHANGELOG_COMMITS=$(git log --pretty="format:- %s" --no-merges "$LAST_TAG"..HEAD || true) |
| 144 | + fi |
| 145 | + if [ -z "$CHANGELOG_COMMITS" ]; then |
| 146 | + CHANGELOG_COMMITS="- No relevant changes detected since the last release." |
| 147 | + fi |
| 148 | + { |
| 149 | + echo 'commits<<CHANGELOG_EOF' |
| 150 | + echo "$CHANGELOG_COMMITS" |
| 151 | + echo 'CHANGELOG_EOF' |
| 152 | + } >> "$GITHUB_OUTPUT" |
| 153 | +
|
| 154 | + # Generals vc6 |
| 155 | + - name: Download Generals VC6 Artifacts |
| 156 | + uses: actions/download-artifact@v4 |
| 157 | + with: |
| 158 | + name: Generals-vc6+t+e |
| 159 | + path: generals-vc6-artifacts |
| 160 | + |
| 161 | + - name: Prepare and Zip Generals VC6 |
| 162 | + run: | |
| 163 | + mkdir generals-vc6-release |
| 164 | + cp generals-vc6-artifacts/generalsv.exe generals-vc6-release/GeneralsV.exe |
| 165 | + cp generals-vc6-artifacts/W3DViewV.exe generals-vc6-release/W3DViewV.exe |
| 166 | + cp generals-vc6-artifacts/WorldBuilderV.exe generals-vc6-release/WorldBuilderV.exe |
| 167 | + zip -j generals-preview-${{ needs.get-date.outputs.date }}.zip generals-vc6-release/* |
| 168 | +
|
| 169 | + # GeneralsMD vc6 |
| 170 | + - name: Download GeneralsMD VC6 Artifacts |
| 171 | + uses: actions/download-artifact@v4 |
| 172 | + with: |
| 173 | + name: GeneralsMD-vc6+t+e |
| 174 | + path: generalsmd-vc6-artifacts |
| 175 | + |
| 176 | + - name: Prepare and Zip GeneralsMD VC6 |
| 177 | + run: | |
| 178 | + mkdir generalsmd-vc6-release |
| 179 | + cp generalsmd-vc6-artifacts/generalszh.exe generalsmd-vc6-release/GeneralsZHv.exe |
| 180 | + cp generalsmd-vc6-artifacts/W3DViewZH.exe generalsmd-vc6-release/W3DViewZHv.exe |
| 181 | + cp generalsmd-vc6-artifacts/WorldBuilderZH.exe generalsmd-vc6-release/WorldBuilderZHv.exe |
| 182 | + zip -j generalszh-preview-${{ needs.get-date.outputs.date }}.zip generalsmd-vc6-release/* |
| 183 | +
|
| 184 | + - name: Generate release notes |
| 185 | + id: release_body |
| 186 | + run: | |
| 187 | + BODY="" |
| 188 | + if [ "${{ github.event.inputs.build_notes }}" != "" ]; then |
| 189 | + BODY="${BODY}### Build notes\n${{ github.event.inputs.build_notes }}\n" |
| 190 | + fi |
| 191 | + if [ "${{ github.event.inputs.known_issues }}" != "" ]; then |
| 192 | + BODY="${BODY}### Known issues\n${{ github.event.inputs.known_issues }}\n" |
| 193 | + fi |
| 194 | + BODY="${BODY}### Changelog\n${{ steps.changelog.outputs.commits }}" |
| 195 | + echo "body<<EOF" >> $GITHUB_OUTPUT |
| 196 | + echo -e "$BODY" >> $GITHUB_OUTPUT |
| 197 | + echo "EOF" >> $GITHUB_OUTPUT |
| 198 | +
|
| 199 | + - name: Create GitHub Release |
| 200 | + uses: softprops/action-gh-release@v2 |
| 201 | + with: |
| 202 | + tag_name: preview-${{ needs.get-date.outputs.date }} |
| 203 | + name: preview-${{ needs.get-date.outputs.date }} |
| 204 | + prerelease: ${{ github.event.inputs.pre-release == 'true' }} |
| 205 | + body: ${{ steps.release_body.outputs.body }} |
| 206 | + files: | |
| 207 | + generals-preview-${{ needs.get-date.outputs.date }}.zip |
| 208 | + generalszh-preview-${{ needs.get-date.outputs.date }}.zip |
| 209 | + env: |
| 210 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 211 | + |
| 212 | + - name: Clean up release folders |
| 213 | + if: always() |
| 214 | + run: | |
| 215 | + rm -rf generals-vc6-release generalsmd-vc6-release |
| 216 | + rm -rf generals-vc6-artifacts generalsmd-vc6-artifacts |
| 217 | + rm -f generals-preview-${{ needs.get-date.outputs.date }}.zip |
| 218 | + rm -f generalszh-preview-${{ needs.get-date.outputs.date }}.zip |
0 commit comments