Skip to content

Commit 4d49e24

Browse files
committed
publishing
0 parents  commit 4d49e24

File tree

169 files changed

+34438
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+34438
-0
lines changed

.envrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export GOPATH=$( realpath "$PWD/../../../.." )
2+
export GOBIN=$GOPATH/bin
3+
export PATH=$GOBIN:$PATH

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM alpine:3.6
2+
RUN apk --no-cache add bash curl git
3+
RUN \
4+
curl -o /usr/local/bin/bosh http://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-2.0.45-linux-amd64 \
5+
&& echo 'bf04be72daa7da0c9bbeda16fda7fc7b2b8af51e /usr/local/bin/bosh' | sha1sum -c \
6+
&& chmod +x /usr/local/bin/bosh
7+
ADD bin /opt/metalink-upgrader-pipeline/bin

Gopkg.lock

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Gopkg.toml example
3+
#
4+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5+
# for detailed Gopkg.toml documentation.
6+
#
7+
# required = ["github.com/user/thing/cmd/thing"]
8+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
9+
#
10+
# [[constraint]]
11+
# name = "github.com/user/project"
12+
# version = "1.0.0"
13+
#
14+
# [[constraint]]
15+
# name = "github.com/user/project2"
16+
# branch = "dev"
17+
# source = "github.com/myfork/project2"
18+
#
19+
# [[override]]
20+
# name = "github.com/x/y"
21+
# version = "2.4.0"
22+
23+
24+
[[constraint]]
25+
branch = "v2"
26+
name = "gopkg.in/yaml.v2"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Danny Berger <https://dpb587.me>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# metalink-upgrader-pipeline
2+
3+
For managing a [BOSH](https://bosh.io) release pipeline which upgrades blobs from [metalink repositories](https://github.com/dpb587/metalink/tree/master/repository#metalink-repository).
4+
5+
6+
## Usage
7+
8+
A `config/blobs/{blobname}/repository.yml` defines the metalink repository where the blob versions are mirrored.
9+
10+
uri: git+https://github.com/dpb587/upstream-blob-mirror.git//repository/icu4c
11+
version: ^58
12+
13+
A pipeline defines the basic configuration for an upgrader pipeline (`ci/pipelines/upgrader.yml`) which defines, at a minimum, a `repo` resource which references the release repository. After a blob upgrade is triggered, the `config.after_upload_blobs` setting configures what happens after the blobs have been synced.
14+
15+
config:
16+
after_sync_blobs: # run integration tests with a dev release of the new blob
17+
- task: create-dev-release
18+
file: repo/ci/tasks/create-dev-release/task.yml
19+
- task: integration-test
20+
file: repo/ci/tasks/integration-test/task.yml
21+
privileged: true
22+
after_upload_blobs: # push the new blobs to the repo
23+
- put: repo
24+
params:
25+
repository: repo
26+
resources:
27+
- name: repo # the bosh release repository
28+
type: git
29+
source:
30+
uri: git@github.com:dpb587/openvpn-bosh-release.git
31+
branch: master
32+
private_key: ((repo_private_key))
33+
34+
Once the blobs and base pipeline have been configured, `metalink-upgrader-pipeline` can be used to generate a pipeline. The generated pipeline will have a new job to handle updates to the upstream blobs. By configuring steps for `after_upload_blobs`, a `bosh upload-blobs` step will first be executed. The job will require several variables to be set: `release_private_yml` (for uploading blobs to the blobstore) and `maintainer_email`, `maintainer_name` (for the `git` commit).
35+
36+
fly set-pipeline -p openvpn:upgrader \
37+
-c <( metalink-upgrader-pipeline ci/pipelines/upgrader.yml ) \
38+
-l <( lpass show 'pipeline=openvpn:upgrader' )
39+
40+
The blob jobs automatically trigger whenever a new version is available. When syncing blobs, old blobs in the directory are removed, new blobs are added (not yet uploaded), and a copy of the origin metalink is staged to `config/blobs/{blobname}/metalink.meta4`. When uploading blobs, `config/blobs.yml` is updated with the new blobstore references, and any other already-staged files are committed. After uploading blobs, the repository should be pushed.
41+
42+
43+
## Examples
44+
45+
A couple public repositories using this to manage some upstream dependencies.
46+
47+
* [dpb587/openvpn-bosh-release](https://github.com/dpb587/openvpn-bosh-release)
48+
* [dpb587/ssoca-bosh-release](https://github.com/dpb587/ssoca-bosh-release)

bin/sync-blobs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
cp -rp repo/. updated-repo
6+
7+
cd updated-repo/
8+
9+
10+
#
11+
# replace existing blobs
12+
#
13+
14+
for file in $( bosh blobs --column=path | grep "^$blob/" | sed "s#$blob/##g" ); do
15+
if [[ ! -e "../blob/$file" ]]; then
16+
bosh remove-blob "$blob/$file"
17+
18+
continue
19+
fi
20+
21+
new_digest=$( sha1sum "../blob/$file" | awk '{ print $1 }' )
22+
existing_digest=$( bosh blobs --column=path --column=digest | grep "^$blob/$file\s" | awk '{ print $2 }' )
23+
24+
if [[ "$new_digest" == "$existing_digest" ]]; then
25+
echo "$file unchanged"
26+
27+
continue
28+
fi
29+
30+
bosh remove-blob "$blob/$file"
31+
32+
bosh add-blob "../blob/$file" "$blob/$file"
33+
done
34+
35+
36+
#
37+
# add new blobs
38+
#
39+
40+
for file in $( cd ../blob ; find . -type f | grep -v '^./.resource' | cut -c3- ); do
41+
if bosh blobs --column=path | grep -q "^$blob/$file\s" ; then
42+
continue
43+
fi
44+
45+
bosh add-blob "../blob/$file" "$blob/$file"
46+
done
47+
48+
49+
#
50+
# import metalink
51+
#
52+
53+
cp -p ../blob/.resource/metalink.meta4 "config/blobs/$blob/metalink.meta4"
54+
55+
git add "config/blobs/$blob/metalink.meta4"
56+
57+
echo "blobs: Update $blob to $( cat ../blob/.resource/version )" > .git/COMMIT_MSG

bin/upload-blobs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
task_dir=$PWD
6+
7+
cp -rp repo/. updated-repo
8+
9+
cd updated-repo/
10+
11+
12+
#
13+
# env
14+
#
15+
16+
export GIT_COMMITTER_NAME="Concourse"
17+
export GIT_COMMITTER_EMAIL="concourse.ci@localhost"
18+
19+
git config --global user.email "${git_user_email:-ci@localhost}"
20+
git config --global user.name "${git_user_name:-CI Bot}"
21+
22+
23+
#
24+
# upload-blobs
25+
#
26+
27+
cat > config/private.yml <<EOF
28+
${release_private_yml:-}
29+
EOF
30+
31+
bosh upload-blobs
32+
33+
git add config/blobs.yml
34+
35+
36+
#
37+
# commit
38+
#
39+
40+
if git diff --staged --exit-code --quiet ; then
41+
# no changes pending
42+
exit
43+
elif [ -e .git/COMMIT_MSG ] ; then
44+
# use prepared commit message
45+
git commit -F .git/COMMIT_MSG
46+
else
47+
git commit -m "${git_message:-Update blobs}"
48+
fi

0 commit comments

Comments
 (0)