aredn/.circleci/config.yml

313 lines
10 KiB
YAML

version: 2.1
######################################
# PIPELINE PARAMETERS
######################################
parameters:
action:
type: enum
enum: [no_action, nightly_build, manual_build, release_build, afs_collector]
default: no_action
release_version:
type: string
default: "NO_RELEASE_VERSION_SET"
######################################
# 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
update_config_mk_release:
description: "Update variables in config.mk for release"
steps:
- run:
name: Update Config.mk Release
command: |
export MY_WORKING_DIRECTORY=`pwd`
sed -i "s/FW_VERSION=\$(PRIVATE_BUILD_VERSION)-\$(GIT_COMMIT)/FW_VERSION=\$(PRIVATE_BUILD_VERSION)/g" ${MY_WORKING_DIRECTORY}/Makefile
sed -i "s/NoCall/<< pipeline.parameters.release_version >>/g" ${MY_WORKING_DIRECTORY}/config.mk
sed -i "s/snapshots/releases\/3\/23\/<< pipeline.parameters.release_version >>/g" ${MY_WORKING_DIRECTORY}/config.mk
sed -i "s/MAKE_ARGS=-j3/MAKE_ARGS=-j${DASH_J_VALUE}/g" ${MY_WORKING_DIRECTORY}/config.mk
sed -i "s/develop/<< pipeline.parameters.release_version >>/g" ${MY_WORKING_DIRECTORY}/feeds.conf
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}
build_release:
resource_class: large
docker:
- image: arednmesh/builder
steps:
- checkout
- update_config_mk_release
- 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}'"
process_artifacts_release:
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}'"
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
release_build:
when:
equal: [ release_build, << pipeline.parameters.action >> ]
jobs:
- build_release
- process_artifacts_release:
requires:
- build_release
- readme_nightly:
requires:
- process_artifacts_release
- changelog_nightly:
requires:
- process_artifacts_release
- save_build_info:
requires:
- process_artifacts_release
afs_collector_workflow:
when:
equal: [ afs_collector, << pipeline.parameters.action >> ]
jobs:
- afs_collector