version: 2.1 ###################################### # PIPELINE PARAMETERS ###################################### parameters: action: type: enum enum: [no_action, nightly_build, manual_build, release_build] default: no_action ###################################### # REUSABLE COMMANDS ###################################### commands: update_config_mk: description: "Update variables in config.mk" steps: - run: name: Update Config.mk command: | export MY_WORKING_DIRECTORY=`pwd` printf -v BUILD_DATE '%(%Y%m%d)T' -1 sed -i "s/NoCall/${BUILD_DATE}/g" ${MY_WORKING_DIRECTORY}/config.mk sed -i "s/MAKE_ARGS=-j3/MAKE_ARGS=-j${DASH_J_VALUE}/g" ${MY_WORKING_DIRECTORY}/config.mk cat ${MY_WORKING_DIRECTORY}/config.mk ###################################### # JOBS ###################################### jobs: build: resource_class: large docker: - image: arednmesh/builder steps: - checkout - update_config_mk - run: name: Build ath79/generic command: make MAINTARGET=ath79 SUBTARGET=generic no_output_timeout: 2h - run: name: Build ath79/tiny command: make MAINTARGET=ath79 SUBTARGET=tiny no_output_timeout: 1h - run: name: Build ath79/mikrotik command: make MAINTARGET=ath79 SUBTARGET=mikrotik no_output_timeout: 1h - run: name: Build ath79/mikrotik/ath10k command: make MAINTARGET=ath79 SUBTARGET=mikrotik ALTTARGET=ath10k no_output_timeout: 1h - run: name: Build ath79/mikrotik/nand command: make MAINTARGET=ath79 SUBTARGET=mikrotik ALTTARGET=nand no_output_timeout: 1h - run: name: Build ath79/nand command: make MAINTARGET=ath79 SUBTARGET=nand no_output_timeout: 1h - run: name: Build ipq40xx/mikrotik command: make MAINTARGET=ipq40xx SUBTARGET=mikrotik no_output_timeout: 2h - run: name: Build x64/64 command: make MAINTARGET=x86 SUBTARGET=64 no_output_timeout: 2h - run: name: Compress build files command: tar -cjf ~/${CIRCLE_BRANCH}_${ARTIFACTS_FILE} -C ${MY_WORKING_DIRECTORY}/${ARTIFACTS_DIR} . - run: name: Deploy Files command: scp -o StrictHostKeyChecking=no ~/${CIRCLE_BRANCH}_${ARTIFACTS_FILE} ${SSH_USER}@${SSH_HOST}:${TARGET_DIR} check2build: machine: image: ubuntu-2004:2023.02.1 steps: - run: name: Retrieve last build info and check command: ssh ${SSH_USER}@${SSH_HOST} "sh -c ' ~/needs2build.sh ${CIRCLE_PROJECT_USERNAME} ${CIRCLE_PROJECT_REPONAME} ${CIRCLE_BRANCH} ${CIRCLE_SHA1}'" - run: name: Check2build failure (build not needed) when: on_fail command: circleci-agent step halt save_build_info: machine: image: ubuntu-2004:2023.02.1 steps: - run: name: Save last build info command: ssh ${SSH_USER}@${SSH_HOST} "sh -c ' echo ${CIRCLE_SHA1} > ~/build_info/${CIRCLE_PROJECT_USERNAME}_${CIRCLE_PROJECT_REPONAME}_${CIRCLE_BRANCH}'" process_artifacts_nightly: machine: image: ubuntu-2004:2023.02.1 steps: - run: name: Untar Files command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'tar -xjf ${TARGET_DIR}/${CIRCLE_BRANCH}_${ARTIFACTS_FILE} -C ${TARGET_DIR}'" - run: name: Empty nightly dir command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'rm -rf ${NIGHTLY_DIR}'" - run: name: Create nightly dir command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'mkdir -p ${NIGHTLY_DIR}'" - run: name: Move targets command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'mv ${TARGET_DIR}/targets ${NIGHTLY_DIR}'" - run: name: Move packages command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'mv ${TARGET_DIR}/packages ${NIGHTLY_DIR}'" changelog_nightly: machine: image: ubuntu-2004:2023.02.1 steps: - run: name: Generate changelog.md command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'docker run --rm -v ~/:/usr/local/src/your-app ferrarimarco/github-changelog-generator -u ${CIRCLE_PROJECT_USERNAME} -p ${CIRCLE_PROJECT_REPONAME} -t ${GITHUB_TOKEN}'" - run: name: Move changelog command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'mv ~/CHANGELOG.md ${NIGHTLY_DIR}'" readme_nightly: machine: image: ubuntu-2004:2023.02.1 steps: - run: name: Fetch README.md command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'wget https://raw.githubusercontent.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}/README.md'" - run: name: Move README.md command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'mv ~/README.md ${NIGHTLY_DIR}/readme.md'" - run: name: Fetch SUPPORTED_DEVICES.md command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'wget https://raw.githubusercontent.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}/SUPPORTED_DEVICES.md'" - run: name: Move SUPPORTED_DEVICES.md command: ssh ${SSH_USER}@${SSH_HOST} "sh -c 'mv ~/SUPPORTED_DEVICES.md ${NIGHTLY_DIR}/SUPPORTED_DEVICES.md'" afs_collector: machine: image: ubuntu-2004:2023.02.1 steps: - run: name: Run AFS collector command: ssh ${SSH_USER}@${SSH_HOST} "sh -c '${DOWNLOADS_DOCROOT}/afs/misc/collect.py --image-url http://downloads.arednmesh.org/{base}/{target} ${DOWNLOADS_DOCROOT} ${DOWNLOADS_DOCROOT}/afs/www'" no_action: machine: image: ubuntu-2004:2023.02.1 steps: - run: echo "No action needed" ###################################### # Workflows ###################################### workflows: no_action_default: when: equal: [ no_action, << pipeline.parameters.action >> ] jobs: - no_action nightly_build: when: equal: [ nightly_build, << pipeline.parameters.action >> ] jobs: - check2build - build: requires: - check2build - process_artifacts_nightly: requires: - build - readme_nightly: requires: - process_artifacts_nightly - changelog_nightly: requires: - process_artifacts_nightly - afs_collector: requires: - process_artifacts_nightly - save_build_info: requires: - process_artifacts_nightly manual_build: when: equal: [ manual_build, << pipeline.parameters.action >> ] jobs: - build - process_artifacts_nightly: requires: - build - readme_nightly: requires: - process_artifacts_nightly - changelog_nightly: requires: - process_artifacts_nightly - afs_collector: requires: - process_artifacts_nightly - save_build_info: requires: - process_artifacts_nightly