From 76b9acc16543e873ba647c847b37a3e12ec20b11 Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Tue, 8 Jun 2021 04:47:40 +0530 Subject: Builds using GitHub actions (#1467) * Using GH Actions for building, packaging and publishing for all 3 OSes (macos, ubuntu and windows). Handles PR builds, release builds, scheduled nightly builds and manual triggering from the web-ui. * Removed references to travis and appveyor and their respective config files. * Added ability to force rebuild nightlies without new version number. (This should allow us to rerun nightly builds with the same build number. Looks for the trigger comment to contain: 'force build' and 'nightly branch') --- .dockerignore | 2 - .github/workflows/ferdi-builds.yml | 206 +++++++++++++++++++++++++++++++++++++ .travis.yml | 100 ------------------ Dockerfile | 7 +- README.md | 4 +- appveyor.yml | 58 ----------- build-helpers/notarize.js | 2 +- recipes | 2 +- 8 files changed, 214 insertions(+), 167 deletions(-) create mode 100644 .github/workflows/ferdi-builds.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.dockerignore b/.dockerignore index 942a28a9f..00a94efd2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,7 +2,6 @@ .husky/ .stage .tmp -.travis.yml **/.DS_Store **/.env **/.git* @@ -15,7 +14,6 @@ **/npm-debug.log* **/server*.log **/yarn-error.log -appveyor.yml Dockerfile flow-typed out diff --git a/.github/workflows/ferdi-builds.yml b/.github/workflows/ferdi-builds.yml new file mode 100644 index 000000000..199c3ca25 --- /dev/null +++ b/.github/workflows/ferdi-builds.yml @@ -0,0 +1,206 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +# Note: This workflow requires some secrets setup, and set on this repo with the names: + # 'FERDI_PUBLISH_TOKEN' (A GitHub Personal Access Token with appropriate permissions - for publishing the built artifacts) + # 'APPLEID' (The username of your Apple developer account - for notarizing the mac artifacts) + # 'APPLEID_PASSWORD' (An app-specific password - for notarizing the mac artifacts) + # 'CSC_LINK' (The HTTPS link or local path to certificate - for code signing of mac and windows artifacts) + # 'CSC_KEY_PASSWORD' (The password to decrypt the certificate given in CSC_LINK - for code signing of mac and windows artifacts) + +name: Ferdi Builds + +on: + # Push to any tracked branches + push: + branches: [develop, release, nightly] + # PRs only on develop branch + pull_request: + branches: [develop] + # Manual trigger from the UI + workflow_dispatch: + inputs: + message: + description: 'Message for build' + required: true + schedule: + - cron: '0 0 * * *' # every night at 12 am + +env: + USE_HARD_LINKS: false + # DEBUG: electron-builder + +jobs: + check_date: + runs-on: ubuntu-latest + name: Check latest commit + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + steps: + - name: Checkout code along with submodules for the 'nightly' branch if the trigger event is 'scheduled' + uses: actions/checkout@v2 + with: + ref: nightly + submodules: recursive + fetch-depth: 0 + - name: Print latest commit + run: echo ${{ github.sha }} + - name: Setup git configs + run: | + git config user.name github-actions + git config user.email github-actions@github.com + - name: Merge from 'origin/develop' (continue if errored) + if: ${{ github.event_name == 'schedule' }} + continue-on-error: true + run: git merge --no-ff --no-verify --commit -m "Merge remote-tracking branch 'origin/develop' into HEAD" origin/develop + - name: Update submodules (continue if errored) + if: ${{ github.event_name == 'schedule' }} + continue-on-error: true + run: | + echo "Updating submodules" + git submodule update --remote -f + + echo "Committing submodules" + git commit -am "Update submodules" --no-verify || true + + echo "Running linter and tests" + npm run lint && npm run test + + echo "Committing linter fixes" + git commit -am "Apply linter fixes" --no-verify || true + - name: Capture if this is a manually triggered forced rebuild + run: echo "FORCE_REBUILD=${{ contains(github.event.inputs.message, 'force build') }}" >> $GITHUB_ENV + - id: should_run + name: Check whether there are any commits since this run was last triggered and either push or set the output + if: ${{ github.event_name == 'schedule' || env.FORCE_REBUILD == 'true' }} + run: | + CHANGES_COUNT=$(git diff --shortstat origin/nightly | wc -l) + echo "Number of changes: $CHANGES_COUNT" + if [ $CHANGES_COUNT -eq 0 ] && [ $FORCE_REBUILD != "true" ]; then + echo "No changes found - terminating the build" + echo "::set-output name=should_run::false" + else + if [ $FORCE_REBUILD != "true" ]; then + echo "Bumping version number" + npm version prerelease --preid=nightly + fi + + echo "Pushing merge, linter, submodule and version-bump commits" + git push origin nightly --no-verify + fi + + build: + name: '${{ matrix.os }}' + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false' }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-10.15, ubuntu-20.04, windows-2019] + node-version: [14.16.1] + fail-fast: false + steps: + - name: Set env vars for macOS and Linux + if: startsWith(runner.os, 'macOS') || startsWith(runner.os, 'Linux') + run: | + echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV + echo "ELECTRON_CACHE=$HOME/.cache/electron" >> $GITHUB_ENV + echo "ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder" >> $GITHUB_ENV + echo "FORCE_REBUILD_ON_NIGHTLY=${{ contains(github.event.inputs.message, 'force build') && contains(github.event.inputs.message, 'nightly branch') }}" >> $GITHUB_ENV + - name: Set env vars for Windows + if: startsWith(runner.os, 'Windows') + run: | + echo "HOME=$USERPROFILE" >> $GITHUB_ENV + echo "NPM_CACHE=$USERPROFILE\.npm" >> $GITHUB_ENV + echo "ELECTRON_CACHE=$USERPROFILE\.cache\electron" >> $GITHUB_ENV + echo "ELECTRON_BUILDER_CACHE=$USERPROFILE\.cache\electron-builder" >> $GITHUB_ENV + echo "FORCE_REBUILD_ON_NIGHTLY=${{ contains(github.event.inputs.message, 'force build') && contains(github.event.inputs.message, 'nightly branch') }}" >> $GITHUB_ENV + shell: bash + - name: Checkout code along with submodules for the 'nightly' branch if the trigger event is 'scheduled' or this is a forced rebuild on the nightly branch + uses: actions/checkout@v2 + if: ${{ github.event_name == 'schedule' || env.FORCE_REBUILD_ON_NIGHTLY == 'true' }} + with: + submodules: recursive + ref: nightly + - name: Checkout code along with submodules for any branch if the trigger event is NOT 'scheduled' and this is NOT a forced rebuild on the nightly branch + uses: actions/checkout@v2 + if: ${{ github.event_name != 'schedule' && env.FORCE_REBUILD_ON_NIGHTLY != 'true' }} + with: + submodules: recursive + - name: Extract Git branch name from the currently checked out branch (not from the branch where this run was kicked off) + run: echo "GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV + shell: bash + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ${{ env.NPM_CACHE }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Cache electron modules + uses: actions/cache@v2 + env: + cache-name: cache-electron-modules + with: + key: ${{ runner.os }}-${{ env.cache-name }} + path: ${{ env.ELECTRON_CACHE }} + - name: Cache electron-builder modules + uses: actions/cache@v2 + env: + cache-name: cache-electron-builder-modules + with: + key: ${{ runner.os }}-${{ env.cache-name }} + path: ${{ env.ELECTRON_BUILDER_CACHE }} + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - name: Upgrade Xcode version on the macOS 10.15 default runners provided by GH Actions + if: startsWith(runner.os, 'macOS') + run: | + sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/* + sudo xcode-select -s "/Applications/Xcode_12.4.app" + - name: Uninstall locally and reinstall node-gyp globally + if: startsWith(runner.os, 'macOS') || startsWith(runner.os, 'Linux') + run: | + npm uninstall node-gyp + npm i -g node-gyp@8.0.0 && npm config set node_gyp "$(which node-gyp)" + - name: Install node dependencies recursively + run: npx lerna bootstrap + - name: Package recipes + run: npm i && npm run package + working-directory: ./recipes + - name: Run linter and tests + run: npm run lint && npm run test + - name: Build Ferdi without publish for any branch not 'nightly' and not 'release' + if: ${{ env.GIT_BRANCH_NAME != 'nightly' && env.GIT_BRANCH_NAME != 'release' }} + run: npm run build + shell: bash + - name: Build Ferdi with publish for 'nightly' branch + if: ${{ env.GIT_BRANCH_NAME == 'nightly' }} + run: npm run build -- --publish always -c.publish.provider=github -c.publish.owner=${{ github.repository_owner }} -c.publish.repo=nightlies + shell: bash + env: + GH_TOKEN: ${{ secrets.FERDI_PUBLISH_TOKEN }} + APPLEID: ${{ secrets.APPLEID }} + APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }} + CSC_LINK: ${{ secrets.CSC_LINK }} + CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} + WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }} + WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }} + - name: Build Ferdi with publish for 'release' branch + if: ${{ env.GIT_BRANCH_NAME == 'release' }} + run: npm run build -- --publish always -c.publish.provider=github -c.publish.owner=${{ github.repository_owner }} -c.publish.repo=ferdi + shell: bash + env: + GH_TOKEN: ${{ secrets.FERDI_PUBLISH_TOKEN }} + APPLEID: ${{ secrets.APPLEID }} + APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }} + CSC_LINK: ${{ secrets.CSC_LINK }} + CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} + WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }} + WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 554dbddff..000000000 --- a/.travis.yml +++ /dev/null @@ -1,100 +0,0 @@ -matrix: - fast_finish: true - include: - - os: linux - dist: xenial - addons: - apt: - packages: - - libx11-dev - - libxext-dev - - libxss-dev - - libxkbfile-dev - - rpm - env: - - USE_HARD_LINKS=false - - ELECTRON_CACHE=$HOME/.cache/electron - - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder - - os: osx - osx_image: xcode12.4 - env: - - USE_HARD_LINKS=false - - ELECTRON_CACHE=$HOME/.cache/electron - - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder - -language: node_js -node_js: "14.16.1" - -git: - submodules: false -branches: - only: - - develop - - release - - nightly -cache: - directories: - - node_modules - - $HOME/.cache/electron - - $HOME/.cache/electron-builder - -before_install: - - git submodule update --init --recursive - - | - if [ $TRAVIS_BRANCH == "nightly" ]; then - git remote add source https://${GH_TOKEN}@github.com/getferdi/ferdi.git > /dev/null 2>&1 - git fetch source - git merge --no-ff --commit -m "Merge remote-tracking branch 'source/develop' into HEAD [skip ci]" source/develop - CHANGES_COUNT=$(git diff --shortstat HEAD origin/$TRAVIS_BRANCH | wc -l) - echo "Travis event type: $TRAVIS_EVENT_TYPE" - echo "Number of changes: $CHANGES_COUNT" - if [ $CHANGES_COUNT -eq 0 -a $TRAVIS_EVENT_TYPE == "cron" ]; then - export SHOULD_CONTINUE_BUILD="false" - echo "Exporting SHOULD_CONTINUE_BUILD to false for future stages" - else - echo "Found changes, proceeding with submodule updates" - git submodule update --remote --force - git commit -am "Update submodules [skip ci]" --no-verify - echo "Completed merging from develop branch and upgrading submodules" - fi - fi -install: - - | - if [ "$SHOULD_CONTINUE_BUILD" == "false" ]; then - echo "Skipping install stage since SHOULD_CONTINUE_BUILD: $SHOULD_CONTINUE_BUILD" - else - travis_retry npm cache clean -f || travis_terminate 1 - travis_retry npm uninstall node-gyp || travis_terminate 1 - travis_retry npm i -g node-gyp@8.0.0 || travis_terminate 1 - cd recipes && npm i && npm run package && cd .. || travis_terminate 1 - travis_retry npx lerna bootstrap || travis_terminate 1 - fi -before_script: - - | - if [ "$SHOULD_CONTINUE_BUILD" == "false" ]; then - echo "Skipping before_script stage since SHOULD_CONTINUE_BUILD: $SHOULD_CONTINUE_BUILD" - else - npm run lint && npm run test || travis_terminate 1 - fi -script: - - | - if [ "$SHOULD_CONTINUE_BUILD" == "false" ]; then - echo "Terminating the build since there are no changes in a cron-triggered build" - travis_terminate 0 - exit 0 # Note: Bug fix since 'travis_terminate' doesn't seem to exit immediately - else - echo "Building for branch: $TRAVIS_BRANCH" - if [ $TRAVIS_BRANCH == "release" ]; then - travis_retry travis_wait 100 npm run build -- --publish always -c.publish.provider=github -c.publish.owner=getferdi -c.publish.repo=ferdi || travis_terminate 1 - elif [ $TRAVIS_BRANCH == "nightly" ]; then - git commit -am "Apply linter fixes [skip ci]" --no-verify - npm version prerelease --preid=nightly -m "%s and trigger AppVeyor nightly build [skip travisci]" || travis_terminate 1 - if [ $TRAVIS_OS_NAME == "osx" ]; then - git remote add source https://${GH_TOKEN}@github.com/getferdi/ferdi.git > /dev/null 2>&1 - git push -qu source HEAD:$TRAVIS_BRANCH --no-verify >/dev/null 2>&1 - fi - travis_retry travis_wait 100 npm run build -- --publish always -c.publish.provider=github -c.publish.owner=getferdi -c.publish.repo=nightlies || travis_terminate 1 - elif [ "$TRAVIS_PULL_REQUEST_BRANCH" != "i18n" ]; then - travis_retry travis_wait 100 npm run build || travis_terminate 1 - fi - fi diff --git a/Dockerfile b/Dockerfile index 4f772c0da..c94b42539 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,13 +8,14 @@ COPY lerna.json ./ # Note: This is being set to bypass the error with missing git repo information for the 'preval-build-info' module ENV PREVAL_BUILD_INFO_PLACEHOLDERS=true -RUN npm i node-gyp@8.0.0 \ +RUN npm i -g node-gyp@8.0.0 \ + && npm config set node_gyp "$(which node-gyp)" \ && npx lerna bootstrap COPY . . -RUN cd recipes && npm i && npm run package && cd .. \ - && npm run build +RUN cd recipes && npm i && npm run package && cd .. +RUN npm run build FROM busybox diff --git a/README.md b/README.md index 87f2b1947..e937a7c36 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,7 @@ Open Collective backers Open Collective sponsors -Build Status Windows -Build Status Mac & Linux +Build Status Gitter Chat Room

@@ -38,6 +37,7 @@ - [How to get and start using Ferdi](#how-to-get-and-start-using-ferdi) - [Download Ferdi](#download-ferdi) - [Or use Chocolatey (Windows only)](#or-use-chocolatey-windows-only) + - [Or use Windows Package Manager (Windows only)](#or-use-windows-package-manager-windows-only) - [Or use homebrew (macOS or Linux)](#or-use-homebrew-macos-or-linux) - [Or use AUR (Arch Linux)](#or-use-aur-arch-linux) - [What makes Ferdi different from Franz?](#what-makes-ferdi-different-from-franz) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7fd061523..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,58 +0,0 @@ -version: build-{build} -branches: - only: - - develop - - nightly - - release -skip_tags: true -skip_branch_with_pr: true - -cache: - - '%APPDATA%\npm-cache' - - node_modules - - '%USERPROFILE%\.electron' - - '%USERPROFILE%\.electron-builder' - -image: Visual Studio 2019 - -environment: - nodejs_version: "14.16.1" - -install: - - appveyor-retry git submodule update --init --recursive - - ps: Update-NodeJsInstallation $env:nodejs_version - - cmd: set NODE_OPTIONS=--max-old-space-size=2048 - - cd recipes && npm i && npm run package && cd .. - - appveyor-retry npx lerna bootstrap - -before_build: - - npm run lint && npm test - - cmd: set NODE_ENV=production - -build_script: - - appveyor-retry npm run build - -for: -- - branches: - only: - - develop - build_script: - - appveyor-retry npm run build - skip_commits: - files: - - src/i18n/**/*.json -- - branches: - only: - - nightly - only_commits: - message: /trigger AppVeyor nightly build/ - build_script: - - appveyor-retry npm run build -- --publish always -c.publish.provider=github -c.publish.owner=getferdi -c.publish.repo=nightlies -- - branches: - only: - - release - build_script: - - appveyor-retry npm run build -- --publish always -c.publish.provider=github -c.publish.owner=getferdi -c.publish.repo=ferdi diff --git a/build-helpers/notarize.js b/build-helpers/notarize.js index cb83808ad..d5a6027fb 100644 --- a/build-helpers/notarize.js +++ b/build-helpers/notarize.js @@ -2,7 +2,7 @@ const { notarize } = require("electron-notarize"); exports.default = async function notarizing(context) { const { electronPlatformName, appOutDir } = context; - if (electronPlatformName !== "darwin" || (process.env.TRAVIS_BRANCH !== 'release' && process.env.TRAVIS_BRANCH !== 'nightly')) { + if (electronPlatformName !== "darwin" || (process.env.GIT_BRANCH_NAME !== 'release' && process.env.GIT_BRANCH_NAME !== 'nightly')) { return; } diff --git a/recipes b/recipes index e05d27ea4..19a224623 160000 --- a/recipes +++ b/recipes @@ -1 +1 @@ -Subproject commit e05d27ea49929e763906e6c430ec79c1a093dde7 +Subproject commit 19a224623d8b4b2302994ccab050b463d0ee817d -- cgit v1.2.3-70-g09d2