Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto update packages #249

Merged
merged 41 commits into from Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bf96dc2
Auto update packages
osterman Nov 6, 2019
6f31214
test action
osterman Nov 6, 2019
87af937
fix version
osterman Nov 6, 2019
4c64c52
fix version
osterman Nov 6, 2019
d8bb219
add a rate limit
osterman Nov 6, 2019
28eb779
move target
osterman Nov 6, 2019
11564e3
fix install path
osterman Nov 6, 2019
9d23dac
Merge branch 'master' into auto-update
osterman Nov 6, 2019
74d0046
Merge branch 'master' into auto-update
osterman Nov 7, 2019
3213f68
Fix target
osterman Nov 7, 2019
8903d67
package fixes
osterman Nov 7, 2019
ba39906
set shell to /bin/bash
osterman Nov 7, 2019
4d6575c
force bash shell
osterman Nov 7, 2019
e54f188
more fixes
osterman Nov 7, 2019
d55acf8
yes, i want bash
osterman Nov 7, 2019
af82487
scratches head
osterman Nov 7, 2019
d38ecf8
whatevs
osterman Nov 7, 2019
f01e904
use alpine
osterman Nov 7, 2019
c0438ce
set shell
osterman Nov 7, 2019
cc9920a
triage
osterman Nov 7, 2019
1ccc82d
debug
osterman Nov 7, 2019
8b97118
debug
osterman Nov 7, 2019
ad06c09
debug
osterman Nov 7, 2019
b2ac8f8
debug
osterman Nov 7, 2019
f1f9c91
Disable cloudflare updates
osterman Nov 7, 2019
606bf47
support alternative api
osterman Nov 7, 2019
2cf483a
fix query
osterman Nov 7, 2019
85cb638
restore master versions
osterman Nov 7, 2019
8d53b42
Disable updates of retry
osterman Nov 7, 2019
8aedf2f
Fix figurine
osterman Nov 7, 2019
edfa9a5
whitespace
osterman Nov 7, 2019
7933f10
Merge branch 'master' into auto-update
osterman Nov 7, 2019
2277f27
Merge branch 'master' into auto-update
osterman Nov 7, 2019
fabf395
Add bash
osterman Nov 7, 2019
f4e95d7
merge
osterman Nov 7, 2019
c0b3989
Merge branch 'master' into auto-update
aknysh Nov 7, 2019
809a16f
Enable cron
osterman Nov 7, 2019
632ecc8
Merge branch 'auto-update' of github.com:cloudposse/packages into aut…
osterman Nov 7, 2019
b9a0ce0
Merge branch 'master' into auto-update
osterman Nov 7, 2019
aad62b2
remove outdated comment
osterman Nov 7, 2019
edaaa11
Merge branch 'auto-update' of github.com:cloudposse/packages into aut…
osterman Nov 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/auto-update.yml
@@ -0,0 +1,35 @@
name: Auto Updater

# Enable `pull_request` for debugging
#on: [pull_request]

on:
schedule:
# Update packages nightly
- cron: '0 0 * * *'

jobs:
update-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Update packages
shell: bash
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
id: vars
run: |
make -C vendor auto-update RATE_LIMIT=0.5
make init
make readme/deps
make readme
- name: Create Pull Request
uses: cloudposse/actions/github/create-pull-request@0.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MESSAGE: update packages
PULL_REQUEST_TITLE: Automated Package Updates
PULL_REQUEST_BODY: This is an auto-generated PR with dependency updates.
PULL_REQUEST_BRANCH: package-updates
PULL_REQUEST_BASE: master
BRANCH_SUFFIX: none
9 changes: 7 additions & 2 deletions Makefile
Expand Up @@ -5,13 +5,14 @@ export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG)
export DOCKER_BUILD_FLAGS =

export DEFAULT_HELP_TARGET := help/vendor
export README_DEPS ?= docs/targets.md
export README_DEPS ?= vendor/labeler docs/targets.md

export DIST_CMD ?= cp -a
export DIST_PATH ?= /dist
export INSTALL_PATH ?= /usr/local/bin
export ALPINE_VERSION ?= 3.10

SHELL := /bin/bash

-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)

all: init deps build install run
Expand All @@ -20,6 +21,7 @@ deps:
@exit 0

## Create a distribution by coping $PACKAGES from $INSTALL_PATH to $DIST_PATH
dist: INSTALL_PATH=/usr/local/bin
dist:
mkdir -p $(DIST_PATH)
[ -z "$(PACKAGES)" ] || \
Expand All @@ -34,6 +36,9 @@ push:
run:
docker run -it ${DOCKER_IMAGE_NAME} sh

vendor/labeler:
$(MAKE) -C vendor labeler

## Build alpine packages for testing
docker/build/apk:
docker build -t cloudposse/apkbuild:$(ALPINE_VERSION) -f apk/Dockerfile-$(ALPINE_VERSION) .
Expand Down
2 changes: 1 addition & 1 deletion apk/Dockerfile-3.10
Expand Up @@ -7,5 +7,5 @@ RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/testing" >> /etc/apk/
RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/community" >> /etc/apk/repositories

RUN apk update
RUN apk add make curl alpine-sdk shadow
RUN apk add make curl alpine-sdk shadow bash
RUN echo "auth sufficient pam_shells.so" > /etc/pam.d/chsh
2 changes: 1 addition & 1 deletion apk/Dockerfile-3.7
Expand Up @@ -7,5 +7,5 @@ RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/testing" >> /etc/apk/
RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/community" >> /etc/apk/repositories

RUN apk update
RUN apk add make alpine-sdk shadow
RUN apk add make alpine-sdk shadow bash
RUN echo "auth sufficient pam_shells.so" > /etc/pam.d/chsh
2 changes: 1 addition & 1 deletion apk/Dockerfile-3.8
Expand Up @@ -7,5 +7,5 @@ RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/testing" >> /etc/apk/
RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/community" >> /etc/apk/repositories

RUN apk update
RUN apk add make curl alpine-sdk shadow
RUN apk add make curl alpine-sdk shadow bash
RUN echo "auth sufficient pam_shells.so" > /etc/pam.d/chsh
2 changes: 1 addition & 1 deletion apk/Dockerfile-3.9
Expand Up @@ -7,5 +7,5 @@ RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/testing" >> /etc/apk/
RUN echo "https://alpine.global.ssl.fastly.net/alpine/edge/community" >> /etc/apk/repositories

RUN apk update
RUN apk add make curl alpine-sdk shadow
RUN apk add make curl alpine-sdk shadow bash
RUN echo "auth sufficient pam_shells.so" > /etc/pam.d/chsh
17 changes: 11 additions & 6 deletions bin/github-repo-metadata
Expand Up @@ -2,11 +2,13 @@
# Use bash to keep this from accidentally running under Alpine/Codefresh
# Switch to sh to allow use in Alpine. The script works either way.

set -o pipefail

function fetch() {
local org=$1
local repo=$2
local api=$3
local path=$4
local org="$1"
local repo="$2"
local api="$3"
local path="$4"
local header=""

if [ -n "$GITHUB_TOKEN" ] ; then
Expand All @@ -19,9 +21,13 @@ function fetch() {
api="/${api}"
fi

local ref=$(curl -sSL -H "$header" "https://api.github.com/repos/$org/${repo}${api}" | jq -r "$path")
local url="https://api.github.com/repos/$org/${repo}${api}"
local ref=$(curl -fsSL -H "$header" "${url}" | jq -r "$path")
if [ $? -eq 0 ]; then
echo $ref
else
echo "ERROR: Failed to retrieve ${url}" >&2
exit 1
fi
}

Expand All @@ -34,4 +40,3 @@ else
echo " $0 cloudposse geodesic '' .description"
exit 1
fi

25 changes: 17 additions & 8 deletions tasks/Makefile.package
Expand Up @@ -5,6 +5,7 @@ export OS_ARCH ?= $(shell uname -m)
export INSTALL_PATH ?= /usr/local/bin
export CURL ?= curl --retry 3 --retry-delay 5 --fail -sSL
export PATH := $(PATH):../../bin/
export SHELL := /bin/bash

export TMP ?= /tmp

Expand Down Expand Up @@ -89,13 +90,15 @@ default: info
DESCRIPTION:
@github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) "index" .description | tee DESCRIPTION

VERSION: API=releases/latest
VERSION: QUERY=.tag_name
VERSION:
@version=$$(github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) "releases/latest" .tag_name | sed 's/^v//' | tr -d '\n'); \
@version=$$(github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) '$(API)' '$(QUERY)' | sed 's/^v//' | tr -d '\n'); \
if [ $$? -ne 0 ]; then \
exit 1; \
fi; \
if [ "$${version}" == "null" ] || [ "$${version}" == "" ]; then \
echo "ERROR: failed to obtain current version"; \
if [ "$${version}" == "null" -o "$${version}" == "" ]; then \
echo "ERROR: failed to obtain current version for $(VENDOR)/$(PACKAGE_REPO_NAME)"; \
exit 1; \
else \
echo "$${version}" | tee VERSION; \
Expand All @@ -122,9 +125,13 @@ init: VERSION LICENSE DESCRIPTION RELEASE

update: CURRENT_VERSION RELEASE

sleep: RATE_LIMIT=0
sleep:
sleep $(RATE_LIMIT)

auto-update:
@if [ "$${AUTO_UPDATE_ENABLED}" == "true" ]; then \
$(MAKE) update; \
@if [ "$${AUTO_UPDATE_ENABLED:-true}" == "true" ]; then \
$(MAKE) --quiet --silent --no-print-directory update; \
exit $?; \
else \
echo "Automatic updates disabled for $${PACKAGE_NAME}"; \
Expand All @@ -135,13 +142,15 @@ auto-update:
.PHONY: CURRENT_VERSION

# Update the VERSION file only if it would change, to avoid triggering unnecessary builds
CURRENT_VERSION: API=releases/latest
CURRENT_VERSION: QUERY=.tag_name
CURRENT_VERSION:
@local_version=$$(cat VERSION || echo 0); \
current_version=$$(env PATH=$(PATH) github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) "releases/latest" .tag_name | sed 's/^v//'); \
current_version=$$(env PATH=$(PATH) github-repo-metadata $(VENDOR) $(PACKAGE_REPO_NAME) '$(API)' '$(QUERY)' | sed 's/^v//'); \
if [ $$? -ne 0 ]; then \
exit 1; \
elif [ "$${current_version}" == "null" ] || [ "$${current_version}" == "" ]; then \
echo "ERROR: failed to obtain current version (got: $${current_version})"; \
elif [ "$${current_version}" == "null" -o -z "$${current_version}" ]; then \
echo "ERROR: failed to obtain current version for $(VENDOR)/$(PACKAGE_REPO_NAME) (got: $${current_version})"; \
exit 1; \
elif [ "$${local_version}" != "$${current_version}" ]; then \
echo "Upgrading $(PACKAGE_NAME) from $${local_version} to $${current_version}"; \
Expand Down
4 changes: 3 additions & 1 deletion vendor/Makefile
Expand Up @@ -5,6 +5,8 @@ APK_PACKAGE_REPOS ?= $(addprefix $(APK_PACKAGES_PATH)/,$(REPOS))
APK_PACKAGE_INDEX ?= $(addsuffix /APKINDEX.tar.gz,$(APK_PACKAGE_REPOS))
APK_PACKAGES ?= $(wildcard $(addsuffix /*.apk,$(APK_PACKAGE_REPOS)))

SHELL := /bin/bash

default: build

## Install alpine build deps
Expand All @@ -27,7 +29,7 @@ labeler:

## Update all packages
auto-update:
find . -mindepth 1 -maxdepth 1 -type d | xargs -I{} bash -c 'make -C {} auto-update || exit 255'
find . -mindepth 1 -maxdepth 1 -type d | xargs -I{} bash -c 'make --no-print-directory --quiet --silent -C {} auto-update || exit 255'

# Rebuild the APKINDEX if it's older than any of the *.apk files
$(APK_PACKAGE_INDEX): $(APK_PACKAGES)
Expand Down
1 change: 1 addition & 0 deletions vendor/cloudflared/Makefile
Expand Up @@ -7,6 +7,7 @@ export PACKAGE_HOMEPAGE_URL = https://developers.cloudflare.com/argo-tunnel/down
export DOWNLOAD_URL ?= https://bin.equinox.io/c/VdrWdbjqyF/$(PACKAGE_NAME)-stable-$(OS)-$(ARCH).tgz
export APK_BUILD_TEMPLATE ?= APKBUILD.github-binary
export APKBUILD_DEPENDS += libc6-compat
export AUTO_UPDATE_ENABLED = false

# Releases: https://developers.cloudflare.com/argo-tunnel/downloads/
## Install cloudflared which offers an easy way to expose web servers securely to the internet(Argo Tunnel)
Expand Down
1 change: 0 additions & 1 deletion vendor/figurine/Makefile
Expand Up @@ -17,4 +17,3 @@ package/prepare::

test:
$(PACKAGE_EXE) --help

2 changes: 2 additions & 0 deletions vendor/kops-1.12/Makefile
@@ -1,6 +1,7 @@
export MASTER_PACKAGE_NAME = kops
export MAJOR_VERSION = 1.12
export PACKAGE_NAME = $(MASTER_PACKAGE_NAME)-$(MAJOR_VERSION)
export PACKAGE_REPO_NAME = kops
export DOWNLOAD_URL = https://github.com/kubernetes/kops/releases/download/$(PACKAGE_VERSION)/kops-$(OS)-$(ARCH)

include ../../tasks/Makefile.package
Expand All @@ -13,6 +14,7 @@ export APK_BUILD_TEMPLATE = APKBUILD.github-binary
export APKBUILD_DEPENDS += dpkg
export APKBUILD_INSTALL_SCRIPTS = $(PACKAGE_NAME).post-install $(PACKAGE_NAME).post-deinstall
export INSTALL_DIR = /usr/share/${MASTER_PACKAGE_NAME}/${MAJOR_VERSION}/bin
export AUTO_UPDATE_ENABLED = false

install:
$(call download_binary)
Expand Down
3 changes: 3 additions & 0 deletions vendor/retry/Makefile
Expand Up @@ -12,6 +12,9 @@ export VENDOR ?= kamilsk
export DOWNLOAD_URL ?= $(PACKAGE_REPO_URL)/releases/download/$(PACKAGE_VERSION)/$(PACKAGE_NAME)_$(PACKAGE_VERSION)_$(OS)-64bit.tar.gz
export APK_BUILD_TEMPLATE ?= APKBUILD.github-binary

# Releases are no longer published: https://github.com/kamilsk/retry/releases
export AUTO_UPDATE_ENABLED = false

install:
$(call download_tarball)

Expand Down
3 changes: 3 additions & 0 deletions vendor/shellcheck/Makefile
@@ -1,6 +1,9 @@
include ../../tasks/Makefile.package
include ../../tasks/Makefile.apk

CURRENT_VERSION: QUERY=first(.[] | .name)
CURRENT_VERSION: API=tags

# Package details
export VENDOR ?= koalaman
export DOWNLOAD_URL ?= https://storage.googleapis.com/shellcheck/shellcheck-v$(PACKAGE_VERSION).$(OS).x86_64.tar.xz
Expand Down