From 94bd5db97135b91d79388cf8a6a763be1ac3462f Mon Sep 17 00:00:00 2001 From: "Oleg V. Kozlyuk" Date: Mon, 22 Jul 2024 23:47:14 +0200 Subject: [PATCH] Workflows refactor, added release workflow --- .github/workflows/nightly.yml | 49 ++++++++ .github/workflows/on-push.yml | 24 ++++ .github/workflows/release.yml | 64 ++++++++++ .../{build.yml => reusable-build.yml} | 114 ++++++------------ 4 files changed, 175 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/nightly.yml create mode 100644 .github/workflows/on-push.yml create mode 100644 .github/workflows/release.yml rename .github/workflows/{build.yml => reusable-build.yml} (55%) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..15ac1fd2b --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,49 @@ +name: Nightly + +on: + workflow_dispatch: + schedule: + - cron: "13 01 * * *" + +permissions: + contents: write + actions: read + +jobs: + build: + name: Build + uses: ./.github/workflows/reusable-build.yml + strategy: + fail-fast: false + matrix: + architecture: [x64, x86] + with: + architecture: ${{ matrix.architecture }} + upload: true + + publish: + name: Package + needs: [build, build] + runs-on: windows-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + + - name: Re-arrange artifacts + shell: cmd + run: | + dir /S /B + move Orbiter-x64\Orbiter.zip Orbiter-x64.zip + move Orbiter-x86\Orbiter.zip Orbiter-x86.zip + dir /S /B + + - name: "Create nightly release" + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ github.token }}" + automatic_release_tag: "latest" + prerelease: true + title: "Orbiter development build" + files: | + Orbiter-x86.zip + Orbiter-x64.zip diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml new file mode 100644 index 000000000..cd91add79 --- /dev/null +++ b/.github/workflows/on-push.yml @@ -0,0 +1,24 @@ +name: On Push + +on: + push: + branches: + - main + paths-ignore: [ 'Doc/**', 'Flights/**', 'Html/**', 'Images/**', 'Localdoc/**', 'Scenarios/**', 'Textures/**', 'Textures2/**'] + pull_request: + branches: + - main + paths-ignore: [ 'Doc/**', 'Flights/**', 'Html/**', 'Images/**', 'Localdoc/**', 'Scenarios/**', 'Textures/**', 'Textures2/**'] + +jobs: + build: + name: Push + strategy: + fail-fast: false + matrix: + architecture: [x64, x86] + os: [windows-2019, windows-2022] # Why do we need multiple Windows versions? + uses: ./.github/workflows/reusable-build.yml + with: + os: ${{ matrix.os }} + architecture: ${{ matrix.architecture }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..fac17421c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,64 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + required: true + type: string + default: 2024.1.0 + +run-name: Release ${{ inputs.version }} + +permissions: + actions: read + contents: write + +env: + artifact-name: Orbiter-${{ inputs.version }}.zip + +jobs: + build: + name: Build + uses: ./.github/workflows/reusable-build.yml + strategy: + fail-fast: false + matrix: + architecture: [x64, x86] + with: + architecture: ${{ matrix.architecture }} + upload: true + + package: + name: Package + needs: [build] + runs-on: ubuntu-latest + permissions: + actions: read + contents: write + steps: + - uses: actions/download-artifact@v4 + with: + name: Orbiter-x86 + path: Orbiter-x86 + + - uses: actions/download-artifact@v4 + with: + name: Orbiter-x64 + path: Orbiter-x64 + + - run: | + find . + mv Orbiter-x86/Orbiter.zip Orbiter-x86.zip + mv Orbiter-x64/Orbiter.zip Orbiter-x64.zip + + - name: "Create nightly release" + uses: softprops/action-gh-release@v2 + with: + body: https://orbiter.voron.software/downloads/Orbiter-${{ inputs.version }}.zip + tag_name: ${{ inputs.version }} + prerelease: false + name: Orbiter ${{ inputs.version }} + files: | + Orbiter-x86.zip + Orbiter-x64.zip diff --git a/.github/workflows/build.yml b/.github/workflows/reusable-build.yml similarity index 55% rename from .github/workflows/build.yml rename to .github/workflows/reusable-build.yml index df2d48b3f..d8a83392e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/reusable-build.yml @@ -1,30 +1,33 @@ name: Build on: - push: - branches: - - main - paths-ignore: [ 'Doc/**', 'Flights/**', 'Html/**', 'Images/**', 'Localdoc/**', 'Scenarios/**', 'Textures/**', 'Textures2/**'] - pull_request: - branches: - - main - paths-ignore: [ 'Doc/**', 'Flights/**', 'Html/**', 'Images/**', 'Localdoc/**', 'Scenarios/**', 'Textures/**', 'Textures2/**'] + workflow_call: + inputs: + os: + default: windows-2019 + type: string + architecture: + description: 'Build Architecture' + default: x86 + type: string + upload: + description: Upload resulting artifact? + type: boolean + default: false + +run-name: Build ${{ inputs.architecture }} on ${{ inputs.os }} + +permissions: + contents: read jobs: build: name: Build + runs-on: ${{ inputs.os }} env: DXSDK_DIR: "${{ github.workspace }}\\DXSDK" - strategy: - fail-fast: false - matrix: - architecture: [x64, x86] - os: [windows-2019, windows-2022] - - runs-on: ${{ matrix.os }} - steps: - name: Checkout uses: actions/checkout@v4 @@ -37,7 +40,7 @@ jobs: - name: Setup MSVC Console uses: ilammy/msvc-dev-cmd@v1 with: - arch: ${{ matrix.architecture }} + arch: ${{ inputs.architecture }} - name: Create directories run: | @@ -47,8 +50,8 @@ jobs: - name: Cache irrKlang package uses: actions/cache@v4 with: - path: ${{ github.workspace }}/Extern/irrKlang/${{ matrix.architecture }} - key: irrKlang-${{ matrix.architecture }} + path: ${{ github.workspace }}/Extern/irrKlang/${{ inputs.architecture }} + key: irrKlang-${{ inputs.architecture }} - name: Cache DirectX SDK id: cache @@ -68,16 +71,16 @@ jobs: dir /S /B DXSDK - name: Configure - run: cmake . --preset windows-${{ matrix.architecture }}-release -DORBITER_MAKE_DOC=OFF -DDXSDK_DIR:PATH="${{ github.workspace }}\\DXSDK" + run: cmake . --preset windows-${{ inputs.architecture }}-release -DORBITER_MAKE_DOC=OFF -DDXSDK_DIR:PATH="${{ github.workspace }}\\DXSDK" - name: Build - run: cmake --build --preset windows-${{ matrix.architecture }}-release --jobs 2 + run: cmake --build --preset windows-${{ inputs.architecture }}-release --jobs 2 - name: Test - run: ctest --preset windows-${{ matrix.architecture }}-release --jobs 2 + run: ctest --preset windows-${{ inputs.architecture }}-release --parallel 2 - name: Install - working-directory: ${{ github.workspace }}/out/build/windows-${{ matrix.architecture }}-release + working-directory: ${{ github.workspace }}/out/build/windows-${{ inputs.architecture }}-release run: cmake --install . --prefix ${{ github.workspace }}/out/install - name: List exports @@ -91,71 +94,30 @@ jobs: del /Q exports_tmp*.txt - name: Diff exports with Orbiter 2016 - if: ${{ matrix.architecture == 'x86' }} + if: ${{ inputs.architecture == 'x86' }} shell: cmd continue-on-error: true run: git diff -U0 --ignore-cr-at-eol --ignore-space-at-eol --no-index exports.2016.txt out/install/Orbiter/exports.txt - - name: Upload exports - if: ${{ matrix.os == 'windows-2019' }} - uses: actions/upload-artifact@v4 - with: - name: exports-${{ matrix.architecture }} - path: ${{ github.workspace }}/out/install/Orbiter/exports.txt - retention-days: 1 - - name: Pack if: ${{ github.ref == 'refs/heads/main' }} working-directory: ${{ github.workspace }}/out/install/Orbiter shell: cmd run: '7z a "${{ github.workspace }}/out/Orbiter.zip" .' + - name: Upload exports + if: inputs.upload + uses: actions/upload-artifact@v4 + with: + name: exports-${{ inputs.architecture }} + path: ${{ github.workspace }}/out/install/Orbiter/exports.txt + retention-days: 1 + - name: Upload Build Artifact - if: ${{ github.ref == 'refs/heads/main' && matrix.os == 'windows-2019' }} uses: actions/upload-artifact@v4 + if: inputs.upload with: - name: Orbiter-${{ matrix.architecture }} + name: Orbiter-${{ inputs.architecture }} # A file, directory or wildcard pattern that describes what to upload path: ${{ github.workspace }}/out/Orbiter.zip - retention-days: 60 - - pre-release: - name: Publish pre-release - - needs: build - - runs-on: ubuntu-latest - - if: ${{ github.ref == 'refs/heads/main' }} - - steps: - - name: Create directories - run: mkdir out - - - name: Checkout - uses: actions/checkout@v4 - - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - path: ./out - - - name: Re-arrange artifacts - run: | - mv ./Orbiter-x64/Orbiter.zip ./Orbiter-x64.zip - mv ./Orbiter-x86/Orbiter.zip ./Orbiter-x86.zip - rmdir Orbiter-x64 - rmdir Orbiter-x86 - ls -R - working-directory: ./out - - - name: "Push pre-release tag and upload packages" - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" - prerelease: true - title: "Orbiter development build" - files: | - ./out/Orbiter-x86.zip - ./out/Orbiter-x64.zip + retention-days: 1