CI: Support for package deployment.

A pacman repository is now generated with built packages, and exported by
AppVeyor to Bintray. Similar export can now be implemented for Drone, and
services other than Bintray can also be used.
This commit is contained in:
Renato Silva
2016-03-17 12:55:56 -03:00
parent 14f11892dc
commit 35e1904fdf
3 changed files with 64 additions and 2 deletions

View File

@@ -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

View File

@@ -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'

View File

@@ -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; }