diff --git a/appveyor.yml b/appveyor.yml index 52d43ae0..fe75a051 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,25 @@ +environment: + DEPLOY_ACCOUNT: Alexpux + PACMAN_REPOSITORY_NAME: ci.msys + PACMAN_REPOSITORY_URL: https://dl.bintray.com/$(APPVEYOR_ACCOUNT_NAME)/msys2 + BUILD_URL: https://ci.appveyor.com/project/$(APPVEYOR_ACCOUNT_NAME)/$(APPVEYOR_PROJECT_NAME)/build/$(APPVEYOR_BUILD_VERSION) + build_script: # TODO: implement update-core --noconfirm and replace the below command line - C:\msys64\usr\bin\pacman --sync --refresh --refresh --needed --noconfirm msys2-runtime msys2-runtime-devel bash pacman pacman-mirrors - C:\msys64\usr\bin\bash --login -c "$(cygpath ${APPVEYOR_BUILD_FOLDER})/ci-build.sh" + +artifacts: + - path: artifacts\* + +deploy: + - provider: BinTray + username: $(APPVEYOR_ACCOUNT_NAME) + subject: $(APPVEYOR_ACCOUNT_NAME) + package: $(PACMAN_REPOSITORY_NAME) + version: latest + publish: true + override: true + repo: msys2 + api_key: + secure: BINTRAY_TOKEN_ENCRYPTED_BY_APPVEYOR diff --git a/ci-build.sh b/ci-build.sh index dc142eda..eb61499d 100644 --- a/ci-build.sh +++ b/ci-build.sh @@ -7,6 +7,7 @@ # Configure cd "$(dirname "$0")" source 'ci-library.sh' +deploy_enabled && mkdir artifacts git_config user.email 'ci@msys2.org' git_config user.name 'MSYS2 Continuous Integration' git remote add upstream 'https://github.com/Alexpux/MSYS2-packages' @@ -23,7 +24,17 @@ define_build_order || failure 'Could not determine build order' message 'Building packages' "${packages[@]}" execute 'Upgrading the system' pacman --noconfirm --noprogressbar --sync --refresh --refresh --sysupgrade for package in "${packages[@]}"; do - execute 'Building' makepkg --noconfirm --noprogressbar --skippgpcheck --nocheck --syncdeps --rmdeps --cleanbuild + execute 'Building binary' makepkg --noconfirm --noprogressbar --skippgpcheck --nocheck --syncdeps --rmdeps --cleanbuild + execute 'Building source' makepkg --noconfirm --noprogressbar --skippgpcheck --allsource yes|execute 'Installing' pacman --noprogressbar --upgrade *.pkg.tar.xz + deploy_enabled && mv "${package}"/*.pkg.tar.xz artifacts + deploy_enabled && mv "${package}"/*.src.tar.gz artifacts + unset package done -success 'All packages built and installed successfully' + +# Deploy +deploy_enabled && cd artifacts || success 'All packages built successfully' +execute 'Generating pacman repository' create_pacman_repository "${PACMAN_REPOSITORY_NAME:-ci-build}" "${PACMAN_REPOSITORY_URL}" +execute 'Generating build references' create_build_references "${PACMAN_REPOSITORY_NAME:-ci-build}" "${PACMAN_REPOSITORY_URL}" +execute 'SHA-256 checksums' sha256sum * +success 'All artifacts built successfully' diff --git a/ci-library.sh b/ci-library.sh index a0b0b371..230dfc69 100644 --- a/ci-library.sh +++ b/ci-library.sh @@ -119,6 +119,36 @@ define_build_order() { packages=("${sorted_packages[@]}") } +# Associate artifacts with this build +create_build_references() { + local repository_name="${1}" + local repository_url="${2}" + local references="${repository_name}.builds" + test -n "${repository_url}" && wget --no-verbose "${repository_url}/${references}" || touch "${references}" + for file in *; do + sed -i "/^${file}.*/d" "${references}" + printf '%-80s%s\n' "${file}" "${BUILD_URL}" >> "${references}" + done + sort "${references}" | tee "${references}.sorted" | sed -r 's/(\S+)\s.*\/([^/]+)/\2\t\1/' + mv "${references}.sorted" "${references}" +} + +# Add packages to repository +create_pacman_repository() { + local name="${1}" + local url="${2}" + test -n "${url}" && wget --no-verbose "${url}/${name}".{db,files}{,.tar.xz} || rm -f "${name}".{db,files}{,.tar.xz} + repo-add "${name}.db.tar.xz" *.pkg.tar.xz +} + +# Deployment is enabled +deploy_enabled() { + test -n "${BUILD_URL}" || return 1 + test -n "${DEPLOY_ACCOUNT}" || return 1 + local repository_account="$(git remote get-url origin | cut -d/ -f4)" + [[ "${repository_account}" = "${DEPLOY_ACCOUNT}" ]] +} + # Added commits or changed recipes list_commits() { _list_changes commits '*' '#*::' --pretty=format:'%ai::[%h] %s'; } list_packages() { _list_changes packages '*/PKGBUILD' '%/PKGBUILD' --pretty=format: --name-only; }