Use GitHub actions for builds #21
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build | |
| on: | |
| push: | |
| branches: | |
| - actionPr | |
| pull_request: | |
| types: [opened, synchronize] | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| publisher: James Teh | |
| concurrency: | |
| # There's no point continuing to run a build if it's already outdated by | |
| # another commit. | |
| group: build-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: set env | |
| run: | | |
| if [ $GITHUB_EVENT_NAME == push ]; then | |
| # For example: 2025.3.7.2011,23631c6e | |
| # We add 1800 to GITHUB_RUN_NUMBER because we can't set the | |
| # starting number and we were already past 1700 on AppVeyor. | |
| echo version=`date +%Y.%-m.%-d`.$((GITHUB_RUN_NUMBER + 1800)),${GITHUB_SHA:0:8} >> "$GITHUB_ENV" | |
| else | |
| # For example: pr1234-23631c6e | |
| echo version=${GITHUB_REF_NAME%%/*}-${GITHUB_SHA:0:8} >> "$GITHUB_ENV" | |
| fi | |
| if [ ${{ matrix.os }} == windows-latest ]; then | |
| echo os=windows >> "$GITHUB_ENV" | |
| else | |
| echo os=mac >> "$GITHUB_ENV" | |
| fi | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| # There's no point in building if we're going to fail the build because of | |
| # an unsorted key map, so we do this as early as we can. | |
| - name: check key map | |
| run: python tools/sortKeymap.py -t config/${{ env.os }}/reaper-kb.ini | |
| - name: setup | |
| run: pip install scons | |
| # On Mac, we need php for swell_resgen. | |
| - uses: shivammathur/setup-php@v2 | |
| if: ${{ matrix.os == 'macos-latest' }} | |
| with: | |
| php-version: 8.4 | |
| - name: build | |
| run: scons "publisher=${{ env.publisher }}" version=${{ env.version }} | |
| # We only need to upload the pot on one OS. We arbitrarily pick Windows. | |
| - name: pot | |
| if: ${{ github.event_name == 'push' && matrix.os == 'windows-latest' }} | |
| env: | |
| crowdinAuthToken: ${{ secrets.CROWDIN_AUTH_TOKEN }} | |
| run: | | |
| scons version=${{ env.version }} pot | |
| pip install requests | |
| python ci/crowdinSync uploadPot | |
| # We upload snapshot builds to GitHub Releases so they can be downloaded | |
| # directly rather than being zipped. | |
| - id: uploadBuild | |
| name: upload build | |
| if: ${{ github.event_name == 'push' }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: installer/osara_* | |
| tag_name: snapshots | |
| - id: getBuildUrl | |
| name: get build URL | |
| if: ${{ github.event_name == 'push' }} | |
| run: | | |
| echo ${{ env.os }}Url=${{ fromJSON(steps.uploadBuild.outputs.assets)[0].browser_download_url }} >> "$GITHUB_OUTPUT" | |
| # We upload pull request builds as normal artifacts. | |
| - name: upload PR build | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: osara_${{ env.os }}_${{ env.version }} | |
| path: installer/osara_* | |
| compression-level: 0 | |
| outputs: | |
| # The version is the same on Windows and Mac. Again, we arbitrarily pick | |
| # Windows to export this. | |
| version: ${{ env.version }} | |
| # These will only be set for snapshot builds. | |
| winInstallerUrl: ${{ steps.getBuildUrl.outputs.windowsUrl }} | |
| macInstallerUrl: ${{ steps.getBuildUrl.outputs.macUrl }} | |
| publish: | |
| # This job updates the website with the new readme and snapshots. | |
| if: ${{ github.event_name == 'push' }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: setup | |
| run: pip install markdown | |
| - uses: actions/checkout@v4 | |
| - name: build | |
| env: | |
| version: ${{ needs.build.outputs.version }} | |
| winUrl: ${{ needs.build.outputs.winInstallerUrl }} | |
| macUrl: ${{ needs.build.outputs.macInstallerUrl }} | |
| run: python ci/buildSite | |
| - name: upload | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| # ci/buildSite builds the site in _site/. | |
| path: _site/ | |
| - name: deploy | |
| uses: actions/deploy-pages@v4 |