From 5fa23189d930fc1cf61404b70e5b274a3ac36f63 Mon Sep 17 00:00:00 2001 From: Maximilian Federle Date: Tue, 8 Dec 2020 18:19:33 +0100 Subject: [PATCH] CI: Replace Travis with GitHub Actions (#824) Travis's move away from providing unlimited build time to OSS and its inferior developer experience are the reason for this change. The workflows are simple and straightforward, and the build scripts are mostly 1:1 the same we used on Travis. This avoids vendor lock-in as much as possible in case we need to move somewhere else in the future. We introduce two workflows: 1. CD (cd.yml) Runs on: Commits to master, GitHub releases. Does: Run tests, build release assets, update GitHub edge release or release to developer created GitHub release. Builds & uploads snaps to the Snap Store. 2. Test (test.yml) Runs on: Every commit except those on master and v* tagged ones. I.e. PRs and other branches. Does: Run tests only. Creating a release is now an explicit operation. On the Travis workflow, pushing a tag that begins with "v" will lead to the automatic creation of an associated GitHub release. On GHA, creating a GitHub release by hand will trigger the CD-workflow to build & upload the release assets. Other differences to Travis: - Windows builds on Visual Studio 16 2019 instead of Visual Studio 15 2017. - Snap builds run in docker containers, not directly on the build host. - Snap arm64 builds on amd64 via QEMU user emulation. This is slower than what Travis gave us and should be changed when/if GHA offers ARM64 build runners. - GHA retains build artifacts for 90 days by default. Required secrets: - MACOS_CERTIFICATE_PASSWORD - MACOS_CERTIFICATE_P12 - MACOS_APPSTORE_APP_PASSWORD - MACOS_APPSTORE_USERNAME - MACOS_DEVELOPER_ID - SNAPSTORE_LOGIN Discussion: https://github.com/solvespace/solvespace/issues/807 PR: https://github.com/solvespace/solvespace/pull/824 Fixes #807 --- {.travis => .github/scripts}/build-macos.sh | 0 {.travis => .github/scripts}/build-snap.sh | 0 {.travis => .github/scripts}/build-ubuntu.sh | 0 {.travis => .github/scripts}/build-windows.sh | 7 +- {.travis => .github/scripts}/install-macos.sh | 0 {.travis => .github/scripts}/install-snap.sh | 0 .../scripts}/install-ubuntu.sh | 0 .../scripts}/install-windows.sh | 0 {.travis => .github/scripts}/sign-macos.sh | 0 .github/workflows/cd.yml | 240 ++++++++++++++++++ .github/workflows/test.yml | 41 +++ .travis.yml | 115 --------- .travis/deploy-snap.sh | 8 - .travis/remove-edge.sh | 23 -- .travis/tag-edge.sh | 8 - README.md | 2 +- 16 files changed, 284 insertions(+), 160 deletions(-) rename {.travis => .github/scripts}/build-macos.sh (100%) rename {.travis => .github/scripts}/build-snap.sh (100%) rename {.travis => .github/scripts}/build-ubuntu.sh (100%) rename {.travis => .github/scripts}/build-windows.sh (79%) rename {.travis => .github/scripts}/install-macos.sh (100%) rename {.travis => .github/scripts}/install-snap.sh (100%) rename {.travis => .github/scripts}/install-ubuntu.sh (100%) rename {.travis => .github/scripts}/install-windows.sh (100%) rename {.travis => .github/scripts}/sign-macos.sh (100%) create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml delete mode 100755 .travis/deploy-snap.sh delete mode 100755 .travis/remove-edge.sh delete mode 100755 .travis/tag-edge.sh diff --git a/.travis/build-macos.sh b/.github/scripts/build-macos.sh similarity index 100% rename from .travis/build-macos.sh rename to .github/scripts/build-macos.sh diff --git a/.travis/build-snap.sh b/.github/scripts/build-snap.sh similarity index 100% rename from .travis/build-snap.sh rename to .github/scripts/build-snap.sh diff --git a/.travis/build-ubuntu.sh b/.github/scripts/build-ubuntu.sh similarity index 100% rename from .travis/build-ubuntu.sh rename to .github/scripts/build-ubuntu.sh diff --git a/.travis/build-windows.sh b/.github/scripts/build-windows.sh similarity index 79% rename from .travis/build-windows.sh rename to .github/scripts/build-windows.sh index d237d52..e81fb2a 100755 --- a/.travis/build-windows.sh +++ b/.github/scripts/build-windows.sh @@ -1,8 +1,5 @@ #!/bin/sh -xe -MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" -export PATH=$MSBUILD_PATH:$PATH - mkdir build cd build @@ -14,7 +11,7 @@ if [ "$1" = "release" ]; then fi BUILD_TYPE=RelWithDebInfo cmake \ - -G "Visual Studio 15 2017" \ + -G "Visual Studio 16 2019" \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ -DENABLE_OPENMP="${ENABLE_OPENMP}" \ -DENABLE_LTO=ON \ @@ -23,7 +20,7 @@ if [ "$1" = "release" ]; then else BUILD_TYPE=Debug cmake \ - -G "Visual Studio 15 2017" \ + -G "Visual Studio 16 2019" \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ -DENABLE_OPENMP="ON" \ -DCMAKE_GENERATOR_PLATFORM="Win32" \ diff --git a/.travis/install-macos.sh b/.github/scripts/install-macos.sh similarity index 100% rename from .travis/install-macos.sh rename to .github/scripts/install-macos.sh diff --git a/.travis/install-snap.sh b/.github/scripts/install-snap.sh similarity index 100% rename from .travis/install-snap.sh rename to .github/scripts/install-snap.sh diff --git a/.travis/install-ubuntu.sh b/.github/scripts/install-ubuntu.sh similarity index 100% rename from .travis/install-ubuntu.sh rename to .github/scripts/install-ubuntu.sh diff --git a/.travis/install-windows.sh b/.github/scripts/install-windows.sh similarity index 100% rename from .travis/install-windows.sh rename to .github/scripts/install-windows.sh diff --git a/.travis/sign-macos.sh b/.github/scripts/sign-macos.sh similarity index 100% rename from .travis/sign-macos.sh rename to .github/scripts/sign-macos.sh diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..4cf7ab4 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,240 @@ +name: CD + +on: + push: + branches: + - master + release: + types: + - created + +jobs: + test_ubuntu: + runs-on: ubuntu-18.04 + name: Test Ubuntu + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-ubuntu.sh + - name: Build & Test + run: .github/scripts/build-ubuntu.sh + + test_windows: + runs-on: windows-2019 + name: Test Windows + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-windows.sh + shell: bash + - name: Build & Test + run: .github/scripts/build-windows.sh + shell: bash + + test_macos: + runs-on: macos-latest + name: Test macOS + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-macos.sh + - name: Build & Test + run: .github/scripts/build-macos.sh + + build_release_windows: + needs: [test_ubuntu, test_windows, test_macos] + name: Build Release Windows + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-windows.sh + shell: bash + - name: Build & Test + run: .github/scripts/build-windows.sh release + shell: bash + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: windows + path: build/bin/RelWithDebInfo/solvespace.exe + + build_release_windows_openmp: + needs: [test_ubuntu, test_windows, test_macos] + name: Build Release Windows (OpenMP) + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-windows.sh + shell: bash + - name: Build & Test + run: .github/scripts/build-windows.sh release openmp + shell: bash + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: windows-openmp + path: build/bin/RelWithDebInfo/solvespace-openmp.exe + + build_release_macos: + needs: [test_ubuntu, test_windows, test_macos] + name: Build Release macOS + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-macos.sh + - name: Build & Test + run: .github/scripts/build-macos.sh release + - name: Sign Build + run: .github/scripts/sign-macos.sh + env: + MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} + MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }} + MACOS_APPSTORE_APP_PASSWORD: ${{ secrets.MACOS_APPSTORE_APP_PASSWORD }} + MACOS_APPSTORE_USERNAME: ${{ secrets.MACOS_APPSTORE_USERNAME }} + MACOS_DEVELOPER_ID: ${{ secrets.MACOS_DEVELOPER_ID }} + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: macos + path: build/bin/SolveSpace.dmg + + deploy_snap_amd64: + needs: [test_ubuntu, test_windows, test_macos] + name: Deploy AMD64 Snap + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set Up Source + run: rsync --filter=":- .gitignore" -r ./ pkg/snap/solvespace-snap-src + - name: Build Snap + id: build + uses: diddlesnaps/snapcraft-multiarch-action@v1 + with: + path: pkg/snap + - name: Upload & Release to Edge + if: github.event_name == 'push' + uses: snapcore/action-publish@v1 + with: + store_login: ${{ secrets.SNAPSTORE_LOGIN }} + snap: ${{ steps.build.outputs.snap }} + release: edge + - name: Upload & Release to Beta + Edge + if: github.event_name == 'release' + uses: snapcore/action-publish@v1 + with: + store_login: ${{ secrets.SNAPSTORE_LOGIN }} + snap: ${{ steps.build.outputs.snap }} + release: edge,beta + + deploy_snap_arm64: + needs: [test_ubuntu, test_windows, test_macos] + name: Deploy ARM64 Snap + runs-on: ubuntu-latest + steps: + - uses: docker/setup-qemu-action@v1 + - uses: actions/checkout@v2 + - name: Set Up Source + run: rsync --filter=":- .gitignore" -r ./ pkg/snap/solvespace-snap-src + - name: Build Snap + id: build + uses: diddlesnaps/snapcraft-multiarch-action@v1 + with: + path: pkg/snap + architecture: arm64 + - name: Upload & Release to Edge + if: github.event_name == 'push' + uses: snapcore/action-publish@v1 + with: + store_login: ${{ secrets.SNAPSTORE_LOGIN }} + snap: ${{ steps.build.outputs.snap }} + release: edge + - name: Upload & Release to Beta + Edge + if: github.event_name == 'release' + uses: snapcore/action-publish@v1 + with: + store_login: ${{ secrets.SNAPSTORE_LOGIN }} + snap: ${{ steps.build.outputs.snap }} + release: edge,beta + + update_edge_release: + name: Update Edge Release + needs: [build_release_windows, build_release_windows_openmp, build_release_macos] + if: always() && github.event_name == 'push' + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Delete Old Edge Release + uses: dev-drprasad/delete-tag-and-release@v0.1.2 + with: + delete_release: true + tag_name: edge + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create New Edge Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: edge + release_name: Edge + prerelease: true + draft: false + body: ${{ github.event.head_commit.message }} + + upload_release_assets: + name: Upload Release Assets + needs: [build_release_windows, build_release_windows_openmp, build_release_macos, update_edge_release] + if: always() + runs-on: ubuntu-latest + steps: + - name: Download All Workflow Artifacts + uses: actions/download-artifact@v2 + - name: Get Release Upload URL + id: get_upload_url + env: + event_name: ${{ github.event_name }} + event: ${{ toJson(github.event) }} + edge_upload_url: ${{ needs.update_edge_release.outputs.upload_url }} + run: | + if [ "$event_name" = "release" ]; then + upload_url=$(echo "$event" | jq -r ".release.upload_url") + else + upload_url="$edge_upload_url" + fi + echo "::set-output name=upload_url::$upload_url" + echo "Upload URL: $upload_url" + - name: Upload solvespace.exe + uses: actions/upload-release-asset@v1 + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_upload_url.outputs.upload_url }} + asset_path: windows/solvespace.exe + asset_name: solvespace.exe + asset_content_type: binary/octet-stream + - name: Upload solvespace-openmp.exe + uses: actions/upload-release-asset@v1 + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_upload_url.outputs.upload_url }} + asset_path: windows-openmp/solvespace-openmp.exe + asset_name: solvespace-openmp.exe + asset_content_type: binary/octet-stream + - name: Upload SolveSpace.dmg + uses: actions/upload-release-asset@v1 + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_upload_url.outputs.upload_url }} + asset_path: macos/SolveSpace.dmg + asset_name: SolveSpace.dmg + asset_content_type: binary/octet-stream diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..71b8288 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Test + +on: + push: + branches-ignore: + - master + tags-ignore: + - v* + +jobs: + test_ubuntu: + runs-on: ubuntu-18.04 + name: Test Ubuntu + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-ubuntu.sh + - name: Build & Test + run: .github/scripts/build-ubuntu.sh + + test_windows: + runs-on: windows-2019 + name: Test Windows + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-windows.sh + shell: bash + - name: Build & Test + run: .github/scripts/build-windows.sh + shell: bash + + test_macos: + runs-on: macos-latest + name: Test macOS + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: .github/scripts/install-macos.sh + - name: Build & Test + run: .github/scripts/build-macos.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a692aa7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,115 +0,0 @@ -os: linux -dist: xenial -language: c -git: - submodules: false -if: tag != edge -stages: - - test - - name: clean - if: (NOT type IN (pull_request)) AND (branch = master) - - name: deploy - if: (NOT type IN (pull_request)) AND (branch = master OR tag IS present) -jobs: - include: - - stage: clean - name: Remove Github Release - os: linux - dist: bionic - script: .travis/remove-edge.sh - - stage: test - name: macOS - os: osx - osx_image: xcode12.2 - install: ".travis/install-macos.sh" - script: ".travis/build-macos.sh" - - stage: deploy - name: macOS - os: osx - osx_image: xcode12.2 - install: ".travis/install-macos.sh" - script: ".travis/build-macos.sh release && .travis/sign-macos.sh" - before_deploy: source .travis/tag-edge.sh - deploy: - provider: releases - skip_cleanup: true - prerelease: true - overwrite: true - edge: true - name: ${TRAVIS_TAG:-edge} - release_notes: $TRAVIS_COMMIT_MESSAGE - file: build/bin/SolveSpace.dmg - on: - all_branches: true - - stage: test - name: "Ubuntu" - os: linux - dist: bionic - install: .travis/install-ubuntu.sh - script: .travis/build-ubuntu.sh - - stage: test - name: "Windows" - os: windows - install: .travis/install-windows.sh - script: .travis/build-windows.sh - - stage: deploy - name: "Windows" - os: windows - install: .travis/install-windows.sh - script: .travis/build-windows.sh release - before_deploy: source .travis/tag-edge.sh - deploy: - provider: releases - skip_cleanup: true - prerelease: true - overwrite: true - edge: true - name: ${TRAVIS_TAG:-edge} - release_notes: $TRAVIS_COMMIT_MESSAGE - file: build/bin/RelWithDebInfo/solvespace.exe - on: - all_branches: true - - stage: deploy - name: "Windows with OpenMP" - os: windows - install: .travis/install-windows.sh - script: .travis/build-windows.sh release openmp - before_deploy: source .travis/tag-edge.sh - deploy: - provider: releases - skip_cleanup: true - prerelease: true - overwrite: true - edge: true - name: ${TRAVIS_TAG:-edge} - release_notes: $TRAVIS_COMMIT_MESSAGE - file: build/bin/RelWithDebInfo/solvespace-openmp.exe - on: - all_branches: true - - &deploy-snap - stage: deploy - name: Snap amd64 - os: linux - arch: amd64 - dist: focal - addons: - snaps: - - name: snapcraft - confinement: classic - - name: lxd - install: .travis/install-snap.sh - script: .travis/build-snap.sh - deploy: - - provider: script - script: .travis/deploy-snap.sh edge - skip_cleanup: true - - provider: script - script: .travis/deploy-snap.sh edge,beta - skip_cleanup: true - on: - tags: true - - <<: *deploy-snap - name: Snap arm64 - arch: arm64-graviton2 - group: edge - virt: vm diff --git a/.travis/deploy-snap.sh b/.travis/deploy-snap.sh deleted file mode 100755 index 9cbab5b..0000000 --- a/.travis/deploy-snap.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -e - -channels="$1" -echo "$SNAP_TOKEN" | snapcraft login --with - - -for snap in ./pkg/snap/*.snap; do - snapcraft upload "$snap" --release "$channels" -done diff --git a/.travis/remove-edge.sh b/.travis/remove-edge.sh deleted file mode 100755 index 4321ff5..0000000 --- a/.travis/remove-edge.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -xe - -sudo apt-get update -qq -sudo apt-get -y install jq - -old_release=$(curl \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/solvespace/solvespace/releases/tags/edge \ - | jq -r ".url") - -if [ -z "$old_release" ]; then - curl \ - -X DELETE \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - "$old_release" -fi - -curl \ - -X DELETE \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - https://api.github.com/repos/solvespace/solvespace/git/refs/tags/edge diff --git a/.travis/tag-edge.sh b/.travis/tag-edge.sh deleted file mode 100755 index 8ce6a19..0000000 --- a/.travis/tag-edge.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -xe - -if [ -z "$TRAVIS_TAG" ]; then - git config --local user.name "solvespace-cd" - git config --local user.email "no-reply@solvespace.com" - export TRAVIS_TAG="edge" - git tag --force $TRAVIS_TAG -fi diff --git a/README.md b/README.md index cbeb89f..a367bcb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ SolveSpace ========== -[![Build Status](https://travis-ci.com/solvespace/solvespace.svg?branch=master)](https://travis-ci.com/solvespace/solvespace) +[![Build Status](https://github.com/solvespace/solvespace/workflows/CD/badge.svg)](https://github.com/solvespace/solvespace/actions) [![solvespace](https://snapcraft.io/solvespace/badge.svg)](https://snapcraft.io/solvespace) [![solvespace](https://snapcraft.io/solvespace/trending.svg?name=0)](https://snapcraft.io/solvespace)