Skip to content

Commit 97a0f0d

Browse files
authored
Merge pull request #274 from aborrero/arturo-9350-tw-refresh-for-ste
tw: refresh for stereo
2 parents 803edce + c007043 commit 97a0f0d

File tree

2 files changed

+42
-39
lines changed

2 files changed

+42
-39
lines changed

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,35 @@
22
tw (pronounced tee-dub) is a centralized repository for testing and building
33
tools or helpers.
44

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

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

13-
This takes care of updating the `tw.yaml` file from `melange.yaml`
14-
for wolfi, and syncs the pipeline files for other dirs.
12+
This takes care of updating the `tw.yaml` file from `melange.yaml`,
13+
and syncs the pipeline files for other dirs.
1514

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

1817
## Testing locally
1918

20-
In order to test a tw pipeline in a local melange repository, you need the following steps:
19+
In order to test a tw pipeline in a local stereo repository, you need the following steps:
2120

2221
* Build the tw tools package in this repository, `make build`.
23-
* If required, sync the pipeline yaml to the target melange repository.
24-
* If required, build the melange package with the new pipeline, in the target melange repository.
25-
* If required, test the melange package with the new pipeline, in the target melange repository.
22+
* If required, sync the pipeline yaml to stereo by hand.
23+
* If required, build the melange package with the new pipeline, in the stereo repository.
24+
* If required, test the melange package with the new pipeline, in the stereo repository.
2625

27-
Most likely, you need to tell the melange build in the target local melange repository to use the tw index.
26+
Most likely, you need to tell the melange build in the stereo repository to use the tw index.
2827

2928
A complete example:
3029

3130
```
3231
user@debian:~git/tw $ make build
33-
user@debian:~git/tw $ cp pipelines/test/tw/something.yaml ~/git/enterprise-packages/pipelines/test/tw/
34-
user@debian:~git/tw $ cd ~/git/enterprise-packages/
35-
user@debian:~git/enterprise-packages $ make debug/somepackage
36-
user@debian:~git/enterprise-packages $ MELANGE_DEBUG_TEST_OPTS="--ignore-signatures --repository-append ~/git/tw/packages" make test-debug/somepackage
32+
user@debian:~git/tw $ cp pipelines/test/tw/something.yaml ~/git/stereo/os/pipelines/test/tw/
33+
user@debian:~git/tw $ cd ~/git/stereo/enterprise-packages/
34+
user@debian:~git/stereo/os $ make debug/somepackage
35+
user@debian:~git/stereo/os $ MELANGE_DEBUG_TEST_OPTS="--ignore-signatures --repository-append ~/git/tw/packages" make test-debug/somepackage
3736
```
Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
#!/bin/sh
2+
23
# shellcheck disable=SC2015,SC2039,SC2166,SC3043
4+
set -e
5+
36
VERBOSITY=1
47
# run with 'TWGIT=$PWD' to test locally
58
TWGIT=${TWGIT:-https://github.com/chainguard-dev/tw}
69

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

1013
Usage() {
1114
cat <<EOF
12-
Usage: ${0##*/} tag packages-git-dir/ [ packages-git-dir ...]]
15+
Usage: ${0##*/} tag stereo-git-dir/
1316
14-
Release 'tag' to wolfi, where 'wolfi-os' is a wolfi-dev/os
17+
Release tw 'tag' to stereo, where 'stereo-git-dir/' is a local chainguard-dev/stereo
1518
git checkout.
1619
17-
packages-git-dir is a local git checkout. A commit will be
18-
added to it that has the pipelines/ sync'd.
19-
20-
If the packages-git-dir is wolfi, then melange.yaml will be
21-
copied to tw.yaml.
20+
A commit will be added to it that has the pipelines/ sync'd.
2221
EOF
2322
}
2423

25-
bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || stderr "$@"; return 1; }
24+
bad_Usage() {
25+
[ $# -eq 0 ] || stderr "$@"
26+
Usage
27+
return 1
28+
}
2629
cleanup() {
2730
[ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
2831
}
@@ -31,7 +34,7 @@ debug() {
3134
local level="$1"
3235
shift
3336
[ "$VERBOSITY" -lt "$level" ] && return
34-
stderr "${@}"
37+
echo "${@}"
3538
}
3639

3740
sync_to_dir() {
@@ -57,14 +60,21 @@ sync_to_dir() {
5760
( cd "$gdir" && git add "$d" ) ||
5861
fail "failed to git add $d"
5962
done
63+
}
6064

61-
( cd "$gdir" && git commit -m "tw - bump to $tag" ) ||
62-
fail "failed to commit to $gdir"
63-
return 0
65+
git_commit() {
66+
local stereo_git_dir="$1"
67+
cd "$stereo_git_dir"
68+
git commit -m "tw - bump to $tag"
6469
}
6570

6671

6772
main() {
73+
if [ $# -ne 2 ] ; then
74+
bad_Usage "got $# args expected 2."
75+
return 1
76+
fi
77+
6878
[ "$1" = "--help" ] && { Usage; exit 0; }
6979

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

8090
shift $((OPTIND -1))
8191

82-
[ $# -ge 2 ] || { bad_Usage "got $# args expected 2+"; return 1; }
83-
8492
local tag="$1"
8593
tag=v${tag#v} # chop of 'v' in v0.0.1
8694
shift
8795

88-
local gdir=""
89-
for gdir in "$@"; do
90-
[ -d "$gdir" ] || fail "$gdir: not a directory"
91-
( cd "$gdir" ) || fail "failed to cd $gdir"
92-
done
96+
local stereo_dir="$1"
9397

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

103-
for gdir in "$@"; do
104-
sync_to_dir "$gdir" || exit 1
105-
done
106-
return 0
107+
sync_to_dir "${stereo_dir}/os"
108+
sync_to_dir "${stereo_dir}/enterprise-packages"
109+
sync_to_dir "${stereo_dir}/extra-packages"
110+
git_commit "${stereo_dir}"
107111
}
108112

109113
main "$@"

0 commit comments

Comments
 (0)