Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@
tw (pronounced tee-dub) is a centralized repository for testing and building
tools or helpers.

## Release to Wolfi
To release a version of tw to wolfi, run tools/release-to-wolfi.
## Release to stereo
To release a version of tw to stereo, run tools/release-to-stereo.

$ git tag vX.Y.Z
$ git push origin vX.Y.Z
$ ./tools/release-to-wolfi vX.Y.Z \
~/src/wolfi-os/ ~/src/enterprise-packages ~/src/extra-packages
$ ./tools/release-to-stereo vX.Y.Z ~/git/cg/chainguard-dev/stereo/

This takes care of updating the `tw.yaml` file from `melange.yaml`
for wolfi, and syncs the pipeline files for other dirs.
This takes care of updating the `tw.yaml` file from `melange.yaml`,
and syncs the pipeline files for other dirs.

That will do a commit and you just need to push and do a PR.

## Testing locally

In order to test a tw pipeline in a local melange repository, you need the following steps:
In order to test a tw pipeline in a local stereo repository, you need the following steps:

* Build the tw tools package in this repository, `make build`.
* If required, sync the pipeline yaml to the target melange repository.
* If required, build the melange package with the new pipeline, in the target melange repository.
* If required, test the melange package with the new pipeline, in the target melange repository.
* If required, sync the pipeline yaml to stereo by hand.
* If required, build the melange package with the new pipeline, in the stereo repository.
* If required, test the melange package with the new pipeline, in the stereo repository.

Most likely, you need to tell the melange build in the target local melange repository to use the tw index.
Most likely, you need to tell the melange build in the stereo repository to use the tw index.

A complete example:

```
user@debian:~git/tw $ make build
user@debian:~git/tw $ cp pipelines/test/tw/something.yaml ~/git/enterprise-packages/pipelines/test/tw/
user@debian:~git/tw $ cd ~/git/enterprise-packages/
user@debian:~git/enterprise-packages $ make debug/somepackage
user@debian:~git/enterprise-packages $ MELANGE_DEBUG_TEST_OPTS="--ignore-signatures --repository-append ~/git/tw/packages" make test-debug/somepackage
user@debian:~git/tw $ cp pipelines/test/tw/something.yaml ~/git/stereo/os/pipelines/test/tw/
user@debian:~git/tw $ cd ~/git/stereo/enterprise-packages/
user@debian:~git/stereo/os $ make debug/somepackage
user@debian:~git/stereo/os $ MELANGE_DEBUG_TEST_OPTS="--ignore-signatures --repository-append ~/git/tw/packages" make test-debug/somepackage
```
52 changes: 28 additions & 24 deletions tools/release-to-wolfi → tools/release-to-stereo
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#!/bin/sh

# shellcheck disable=SC2015,SC2039,SC2166,SC3043
set -e

VERBOSITY=1
# run with 'TWGIT=$PWD' to test locally
TWGIT=${TWGIT:-https://github.com/chainguard-dev/tw}

stderr() { echo "$@" 1>&2; }
stderr() { echo "Error: $*" 1>&2; }
fail() { [ $# -eq 0 ] || stderr "$@"; exit 1; }

Usage() {
cat <<EOF
Usage: ${0##*/} tag packages-git-dir/ [ packages-git-dir ...]]
Usage: ${0##*/} tag stereo-git-dir/

Release 'tag' to wolfi, where 'wolfi-os' is a wolfi-dev/os
Release tw 'tag' to stereo, where 'stereo-git-dir/' is a local chainguard-dev/stereo
git checkout.

packages-git-dir is a local git checkout. A commit will be
added to it that has the pipelines/ sync'd.

If the packages-git-dir is wolfi, then melange.yaml will be
copied to tw.yaml.
A commit will be added to it that has the pipelines/ sync'd.
EOF
}

bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || stderr "$@"; return 1; }
bad_Usage() {
[ $# -eq 0 ] || stderr "$@"
Usage
return 1
}
cleanup() {
[ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
}
Expand All @@ -31,7 +34,7 @@ debug() {
local level="$1"
shift
[ "$VERBOSITY" -lt "$level" ] && return
stderr "${@}"
echo "${@}"
}

sync_to_dir() {
Expand All @@ -57,14 +60,21 @@ sync_to_dir() {
( cd "$gdir" && git add "$d" ) ||
fail "failed to git add $d"
done
}

( cd "$gdir" && git commit -m "tw - bump to $tag" ) ||
fail "failed to commit to $gdir"
return 0
git_commit() {
local stereo_git_dir="$1"
cd "$stereo_git_dir"
git commit -m "tw - bump to $tag"
}


main() {
if [ $# -ne 2 ] ; then
bad_Usage "got $# args expected 2."
return 1
fi

[ "$1" = "--help" ] && { Usage; exit 0; }

while getopts "hv" opt; do
Expand All @@ -79,17 +89,11 @@ main() {

shift $((OPTIND -1))

[ $# -ge 2 ] || { bad_Usage "got $# args expected 2+"; return 1; }

local tag="$1"
tag=v${tag#v} # chop of 'v' in v0.0.1
shift

local gdir=""
for gdir in "$@"; do
[ -d "$gdir" ] || fail "$gdir: not a directory"
( cd "$gdir" ) || fail "failed to cd $gdir"
done
local stereo_dir="$1"

TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") ||
fail "failed to make tempdir"
Expand All @@ -100,10 +104,10 @@ main() {
cd tw || fail "failed cd into git cloned $TWGIT"
cksum=$(git rev-parse "$tag") || fail "$tag did not exist"

for gdir in "$@"; do
sync_to_dir "$gdir" || exit 1
done
return 0
sync_to_dir "${stereo_dir}/os"
sync_to_dir "${stereo_dir}/enterprise-packages"
sync_to_dir "${stereo_dir}/extra-packages"
git_commit "${stereo_dir}"
}

main "$@"
Expand Down