From 6ef1f7398583aa709ea2e2ff0bd80074133b4d93 Mon Sep 17 00:00:00 2001 From: Stef Tervelde Date: Mon, 16 Sep 2024 10:05:49 +0200 Subject: [PATCH] CI/CD Updates --- .github/workflows/build.yml | 142 +++++++++++------------------ .github/workflows/pull_request.yml | 62 +++++++++++++ .github/workflows/release.yml | 81 ++++++++++++++++ 3 files changed, 194 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/pull_request.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f2d64120..fba141c99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: Pre-releases on: [push] jobs: @@ -6,89 +6,7 @@ jobs: runs-on: ubuntu-latest name: Run Tests steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Update apt - run: yes | sudo apt-get update - - name: Install rsync - run: yes | sudo apt-get install rsync - - name: Install Java - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - architecture: x64 - - name: Build - run: > - cd build; - ant clean; - ant build - - name: Test - run: > - cd build; - ant test - linux: - runs-on: ubuntu-latest - name: Build Linux - needs: [test] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Update apt - run: yes | sudo apt-get update - - name: Install rsync - run: yes | sudo apt-get install rsync - - name: Install Java - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - architecture: x64 - - name: Build linux - run: > - cd build; - ant clean; - ant build - - name: Add artifact - uses: actions/upload-artifact@v3 - if: ${{ github.ref == 'ref/head/main' }} - with: - name: linux - path: ./build/linux/work - mac: - runs-on: macos-latest - name: Build Mac - needs: [test] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install brew - run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - - name: Install rsync - run: brew install rsync - - name: Install Java - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - architecture: x64 - - name: Build mac - run: > - cd build; - ant clean; - ant build - - name: Add artifact - uses: actions/upload-artifact@v3 - if: ${{ github.ref == 'ref/head/main' }} - with: - name: macos - path: ./build/macos/work - windows: - runs-on: windows-latest - name: Build Windows - needs: [test] - steps: - - name: Checkout + - name: Checkout Repository uses: actions/checkout@v4 - name: Install Java uses: actions/setup-java@v4 @@ -99,11 +17,53 @@ jobs: - name: Build run: > cd build; - ant clean; - ant build - - name: Add artifact - uses: actions/upload-artifact@v3 - if: ${{ github.ref == 'ref/head/main' }} + ant -noinput build test; + build: + name: Create Pre-release for ${{ matrix.os_prefix }} (${{ matrix.arch }}) + needs: test + runs-on: ${{ matrix.os }} + permissions: + contents: write + strategy: + matrix: + include: + # compiling for arm32 needs a self-hosted runner on Raspi OS (32-bit) + - os: self-hosted + os_prefix: linux + arch: arm + - os: ubuntu-latest + os_prefix: linux + arch: x64 + - os: windows-latest + os_prefix: windows + arch: x64 + - os: macos-latest + os_prefix: macos + arch: x64 + - os: macos-latest + os_prefix: macos + arch: aarch64 + - os: macos-latest + os_prefix: linux + arch: aarch64 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Install Java + uses: actions/setup-java@v4 with: - name: windows - path: ./build/windows/work + java-version: '17' + distribution: 'temurin' + architecture: ${{ matrix.arch }} + - name: Setup Ant + uses: cedx/setup-ant@v3 + - name: Build Release + run: ant -noinput -buildfile build/build.xml ${{ matrix.os_prefix }}-dist -Dversion="${{ github.sha }}" + - name: Add artifact + if: ${{ github.ref == 'ref/head/main' }} + uses: actions/upload-artifact@v3 + id: upload + with: + name: processing-${{github.sha}}${{ matrix.os_prefix }}-${{ matrix.arch }} + path: ./build/${{ matrix.os_prefix }}/processing-${{github.sha}}-${{ matrix.os_prefix}}-* + retention-days: 1 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..dff50474c --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,62 @@ +name: Pull Requests +on: + pull_request: + branches: + - main + +jobs: + build: + name: Create Pull Request Build for ${{ matrix.os_prefix }} (${{ matrix.arch }}) + runs-on: ${{ matrix.os }} + permissions: + pull-requests: write + contents: read + strategy: + matrix: + include: + # compiling for arm32 needs a self-hosted runner on Raspi OS (32-bit) + - os: self-hosted + os_prefix: linux + arch: arm + - os: ubuntu-latest + os_prefix: linux + arch: x64 + - os: windows-latest + os_prefix: windows + arch: x64 + - os: macos-latest + os_prefix: macos + arch: x64 + - os: macos-latest + os_prefix: macos + arch: aarch64 + - os: macos-latest + os_prefix: linux + arch: aarch64 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Install Java + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + architecture: ${{ matrix.arch }} + - name: Setup Ant + uses: cedx/setup-ant@v3 + - name: Build Release + run: ant -noinput -buildfile build/build.xml ${{ matrix.os_prefix }}-dist -Dversion="${{ github.sha }}" + - name: Add artifact + uses: actions/upload-artifact@v3 + id: upload + with: + name: processing-${{github.sha}}${{ matrix.os_prefix }}-${{ matrix.arch }} + path: ./build/${{ matrix.os_prefix }}/processing-${{github.sha}}-${{ matrix.os_prefix}}-* + retention-days: 5 + # TODO: Merge into one comment and fix the link + # - uses: mshick/add-pr-comment@v2 + # with: + # message-id: "build-artifact ${{ matrix.os_prefix }} ${{ matrix.arch }}" + # message: | + # Build artifacts for ${{ matrix.os_prefix }} (${{ matrix.arch }}) have been created. + # Download the artifacts [here](${{ steps.upload.outputs.artifact-id }}). \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..df8cac574 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: Releases +on: + push: + tags: + - processing-* + +jobs: + version: + runs-on: ubuntu-latest + outputs: + build_number: ${{ steps.tag_info.outputs.build_number }} + version: ${{ steps.tag_info.outputs.version }} + steps: + - name: Extract version and build number + id: tag_info + shell: bash + run: | + TAG_NAME="${GITHUB_REF#refs/tags/}" + BUILD_NUMBER=$(echo "$TAG_NAME" | cut -d'-' -f2) + VERSION=$(echo "$TAG_NAME" | cut -d'-' -f3) + + # Set outputs for use in later jobs or steps + echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> $GITHUB_OUTPUT + build: + name: Publish Release for ${{ matrix.os_prefix }} (${{ matrix.arch }}) + runs-on: ${{ matrix.os }} + needs: version + permissions: + contents: write + strategy: + matrix: + include: + # compiling for arm32 needs a self-hosted runner on Raspi OS (32-bit) + - os: self-hosted + os_prefix: linux + arch: arm + - os: ubuntu-latest + os_prefix: linux + arch: x64 + - os: windows-latest + os_prefix: windows + arch: x64 + - os: macos-latest + os_prefix: macos + arch: x64 + - os: macos-latest + os_prefix: macos + arch: aarch64 + - os: macos-latest + os_prefix: linux + arch: aarch64 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Install Java + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + architecture: ${{ matrix.arch }} + - name: Setup Ant + uses: cedx/setup-ant@v3 + - name: Install Certificates for Code Signing + if: ${{ matrix.os_prefix == 'macos' }} + uses: apple-actions/import-codesign-certs@v3 + with: + p12-file-base64: ${{ secrets.CERTIFICATES_P12 }} + p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} + - name: Build Release + run: ant -noinput -buildfile build/build.xml ${{ matrix.os_prefix }}-dist -Dversion="${{ needs.version.outputs.version }}" + env: + PROCESSING_APP_PASSWORD: ${{ secrets.PROCESSING_APP_PASSWORD }} + PROCESSING_APPLE_ID: ${{ secrets.PROCESSING_APPLE_ID }} + PROCESSING_TEAM_ID: ${{ secrets.PROCESSING_TEAM_ID }} + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./build/${{ matrix.os_prefix }}/processing-${{ needs.version.outputs.version }}-${{ matrix.os_prefix}}-* + file_glob: true \ No newline at end of file