From 9e1bf844cf821351eff05fbd83ca1317490df6a0 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 11 Jan 2021 02:50:57 +0200 Subject: [PATCH 1/5] also tag image with short version --- bin/build_docker.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/build_docker.sh b/bin/build_docker.sh index 0115acdf..42fade38 100755 --- a/bin/build_docker.sh +++ b/bin/build_docker.sh @@ -12,6 +12,7 @@ IFS=$'\n' REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +SHORT_VERSION="$(echo "$VERSION" | perl -pe 's/(\d+)\.(\d+)\.(\d+)/$1.$2/g')" cd "$REPO_DIR" which docker > /dev/null @@ -20,9 +21,13 @@ echo "[+] Building docker image in the background..." docker build . -t archivebox \ -t archivebox:latest \ -t archivebox:$VERSION \ + -t archivebox:$SHORT_VERSION \ -t docker.io/nikisweeting/archivebox:latest \ -t docker.io/nikisweeting/archivebox:$VERSION \ + -t docker.io/nikisweeting/archivebox:$SHORT_VERSION \ -t docker.io/archivebox/archivebox:latest \ -t docker.io/archivebox/archivebox:$VERSION \ + -t docker.io/archivebox/archivebox:$SHORT_VERSION \ -t docker.pkg.github.com/pirate/archivebox/archivebox:latest \ - -t docker.pkg.github.com/pirate/archivebox/archivebox:$VERSION + -t docker.pkg.github.com/pirate/archivebox/archivebox:$VERSION \ + -t docker.pkg.github.com/pirate/archivebox/archivebox:$SHORT_VERSION From d6854a29ee62d6d5d6b34b6535d26ad8c9e812a9 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 12 Jan 2021 12:51:18 +0200 Subject: [PATCH 2/5] fix apt install without update in deb build --- .github/workflows/debian.yml | 5 +++-- bin/build_docs.sh | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/debian.yml b/.github/workflows/debian.yml index 82a635d0..6492f020 100644 --- a/.github/workflows/debian.yml +++ b/.github/workflows/debian.yml @@ -19,7 +19,8 @@ jobs: - name: Install packaging dependencies run: | - sudo apt install -y \ + sudo apt-get update -qq + sudo apt-get install -y \ python3 python3-dev python3-pip python3-venv python3-all \ dh-python debhelper devscripts dput software-properties-common \ python3-distutils python3-setuptools python3-wheel python3-stdeb @@ -36,7 +37,7 @@ jobs: - name: Install archivebox from deb run: | cd deb_dist/ - sudo apt install ./archivebox*.deb + sudo apt-get install ./archivebox*.deb - name: Check ArchiveBox version run: | diff --git a/bin/build_docs.sh b/bin/build_docs.sh index afc849ed..5fa220fb 100755 --- a/bin/build_docs.sh +++ b/bin/build_docs.sh @@ -20,7 +20,6 @@ fi cd "$REPO_DIR" - echo "[*] Fetching latest docs version" cd "$REPO_DIR/docs" git pull From b0096c7844c51580b6de29bebe53a64aef0bdbc5 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 12 Jan 2021 12:55:38 +0200 Subject: [PATCH 3/5] fix migration failing due to null cmd_versions in older archives --- archivebox/core/migrations/0007_archiveresult.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archivebox/core/migrations/0007_archiveresult.py b/archivebox/core/migrations/0007_archiveresult.py index a780376f..ec48d3ff 100644 --- a/archivebox/core/migrations/0007_archiveresult.py +++ b/archivebox/core/migrations/0007_archiveresult.py @@ -36,7 +36,7 @@ def forwards_func(apps, schema_editor): for extractor in history: for result in history[extractor]: - ArchiveResult.objects.create(extractor=extractor, snapshot=snapshot, cmd=result["cmd"], cmd_version=result["cmd_version"], + ArchiveResult.objects.create(extractor=extractor, snapshot=snapshot, cmd=result["cmd"], cmd_version=result["cmd_version"] or 'unknown', start_ts=result["start_ts"], end_ts=result["end_ts"], status=result["status"], pwd=result["pwd"], output=result["output"]) From 2c69b012c9cfa70d05fe328c2c72940f99bdba27 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 12 Jan 2021 12:56:00 +0200 Subject: [PATCH 4/5] split up release script into subscripts --- bin/build_git.sh | 38 +++++++++++++++++++++++ bin/release.sh | 71 +++++++++---------------------------------- bin/release_brew.sh | 19 ++++++++++++ bin/release_deb.sh | 20 ++++++++++++ bin/release_docker.sh | 24 +++++++++++++++ bin/release_docs.sh | 25 +++++++++++++++ bin/release_git.sh | 25 +++++++++++++++ bin/release_pip.sh | 26 ++++++++++++++++ 8 files changed, 192 insertions(+), 56 deletions(-) create mode 100644 bin/build_git.sh create mode 100644 bin/release_brew.sh create mode 100644 bin/release_deb.sh create mode 100644 bin/release_docker.sh create mode 100644 bin/release_docs.sh create mode 100644 bin/release_git.sh create mode 100644 bin/release_pip.sh diff --git a/bin/build_git.sh b/bin/build_git.sh new file mode 100644 index 00000000..19e185e8 --- /dev/null +++ b/bin/build_git.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +### Bash Environment Setup +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html +# set -o xtrace +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +IFS=$'\n' + +REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" + +cd "$REPO_DIR" +source "./.venv/bin/activate" + + +# Make sure git is clean +if [ -z "$(git status --porcelain)" ] && [[ "$(git branch --show-current)" == "master" ]]; then + git pull +else + echo "[!] Warning: git status is dirty!" + echo " Press Ctrl-C to cancel, or wait 10sec to continue..." + sleep 10 +fi + +# Bump version number in source +function bump_semver { + echo "$1" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g' +} + +OLD_VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +NEW_VERSION="$(bump_semver "$OLD_VERSION")" +echo "[*] Bumping VERSION from $OLD_VERSION to $NEW_VERSION" +contents="$(jq ".version = \"$NEW_VERSION\"" "$REPO_DIR/package.json")" && \ +echo "${contents}" > package.json + diff --git a/bin/release.sh b/bin/release.sh index 12459c74..34256fad 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -11,69 +11,28 @@ set -o pipefail IFS=$'\n' REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" - cd "$REPO_DIR" -source "./.venv/bin/activate" -# Make sure git is clean -if [ -z "$(git status --porcelain)" ] && [[ "$(git branch --show-current)" == "master" ]]; then - git pull -else - echo "[!] Warning: git status is dirty!" - echo " Press Ctrl-C to cancel, or wait 10sec to continue..." - sleep 10 -fi +# Run the linters and tests +# ./bin/lint.sh +# ./bin/test.sh - -# Bump version number in source -function bump_semver { - echo "$1" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g' -} - -OLD_VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" -NEW_VERSION="$(bump_semver "$OLD_VERSION")" -echo "[*] Bumping VERSION from $OLD_VERSION to $NEW_VERSION" -contents="$(jq ".version = \"$NEW_VERSION\"" "$REPO_DIR/package.json")" && \ -echo "${contents}" > package.json - - -# Build docs, python package, and docker image +# Run all the build scripts +./bin/build_git.sh ./bin/build_docs.sh ./bin/build_pip.sh ./bin/build_deb.sh +./bin/build_brew.sh ./bin/build_docker.sh +# Push relase to public repositories +./bin/release_git.sh +./bin/release_docs.sh +./bin/release_pip.sh +./bin/release_deb.sh +./bin/release_brew.sh +./bin/release_docker.sh -# Push build to github -echo "[^] Pushing source to github" -git add "$REPO_DIR/docs" -git add "$REPO_DIR/deb_dist" -git add "$REPO_DIR/pip_dist" -git add "$REPO_DIR/brew_dist" -git add "$REPO_DIR/package.json" -git add "$REPO_DIR/package-lock.json" -git commit -m "$NEW_VERSION release" -git tag -a "v$NEW_VERSION" -m "v$NEW_VERSION" -git push origin master -git push origin --tags - - -# Push releases to github -echo "[^] Uploading to test.pypi.org" -python3 -m twine upload --repository testpypi pip_dist/*.{whl,tar.gz} - -echo "[^] Uploading to pypi.org" -python3 -m twine upload --repository pypi pip_dist/*.{whl,tar.gz} - -echo "[^] Uploading to launchpad.net" -dput archivebox "deb_dist/archivebox_${NEW_VERSION}-1_source.changes" - -echo "[^] Uploading docker image" -# docker login --username=nikisweeting -# docker login docker.pkg.github.com --username=pirate -docker push docker.io/nikisweeting/archivebox -docker push docker.io/archivebox/archivebox -docker push docker.pkg.github.com/archivebox/archivebox/archivebox - -echo "[√] Done. Published version v$NEW_VERSION" +VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +echo "[√] Done. Published version v$VERSION" diff --git a/bin/release_brew.sh b/bin/release_brew.sh new file mode 100644 index 00000000..526d9d59 --- /dev/null +++ b/bin/release_brew.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +### Bash Environment Setup +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html +# set -o xtrace +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +IFS=$'\n' + +REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" +VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +SHORT_VERSION="$(echo "$VERSION" | perl -pe 's/(\d+)\.(\d+)\.(\d+)/$1.$2/g')" +cd "$REPO_DIR" + +# TODO +exit 0 diff --git a/bin/release_deb.sh b/bin/release_deb.sh new file mode 100644 index 00000000..dc1bff35 --- /dev/null +++ b/bin/release_deb.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +### Bash Environment Setup +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html +# set -o xtrace +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +IFS=$'\n' + +REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" +VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +SHORT_VERSION="$(echo "$VERSION" | perl -pe 's/(\d+)\.(\d+)\.(\d+)/$1.$2/g')" +cd "$REPO_DIR" + + +echo "[^] Uploading to launchpad.net" +dput archivebox "deb_dist/archivebox_${VERSION}-1_source.changes" diff --git a/bin/release_docker.sh b/bin/release_docker.sh new file mode 100644 index 00000000..344a456d --- /dev/null +++ b/bin/release_docker.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +### Bash Environment Setup +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html +# set -o xtrace +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +IFS=$'\n' + +REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" +VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +SHORT_VERSION="$(echo "$VERSION" | perl -pe 's/(\d+)\.(\d+)\.(\d+)/$1.$2/g')" +cd "$REPO_DIR" + + +echo "[^] Uploading docker image" +# docker login --username=nikisweeting +# docker login docker.pkg.github.com --username=pirate +docker push docker.io/nikisweeting/archivebox +docker push docker.io/archivebox/archivebox +docker push docker.pkg.github.com/archivebox/archivebox/archivebox diff --git a/bin/release_docs.sh b/bin/release_docs.sh new file mode 100644 index 00000000..114c1262 --- /dev/null +++ b/bin/release_docs.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +### Bash Environment Setup +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html +# set -o xtrace +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +IFS=$'\n' + +REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" +VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +SHORT_VERSION="$(echo "$VERSION" | perl -pe 's/(\d+)\.(\d+)\.(\d+)/$1.$2/g')" +cd "$REPO_DIR" + + +echo "[^] Pushing docs to github" +cd docs/ +git commit -am "$NEW_VERSION release" +git push +git tag -a "v$NEW_VERSION" -m "v$NEW_VERSION" +git push origin master +git push origin --tags diff --git a/bin/release_git.sh b/bin/release_git.sh new file mode 100644 index 00000000..4a999e34 --- /dev/null +++ b/bin/release_git.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +### Bash Environment Setup +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html +# set -o xtrace +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +IFS=$'\n' + +REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" +VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +cd "$REPO_DIR" + + +# Push build to github +echo "[^] Pushing release commit + tag to Github" +git commit -am "$VERSION release" +git tag -a "v$VERSION" -m "v$VERSION" +git push origin master +git push origin --tags +echo " To finish publishing the release go here:" +echo " https://github.com/ArchiveBox/ArchiveBox/releases/new" diff --git a/bin/release_pip.sh b/bin/release_pip.sh new file mode 100644 index 00000000..87323603 --- /dev/null +++ b/bin/release_pip.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +### Bash Environment Setup +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html +# set -o xtrace +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +IFS=$'\n' + +REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )" +VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")" +cd "$REPO_DIR" + + +# apt install python3 python3-all python3-dev +# pip install '.[dev]' + + +echo "[^] Uploading to test.pypi.org" +python3 -m twine upload --repository testpypi pip_dist/archivebox-${VERSION}*.{whl,tar.gz} + +echo "[^] Uploading to pypi.org" +python3 -m twine upload --repository pypi pip_dist/archivebox-${VERSION}*.{whl,tar.gz} From 22aecedbacf34164e629e6753606add3b8fa2602 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 12 Jan 2021 17:14:47 +0200 Subject: [PATCH 5/5] fix perms --- bin/build_git.sh | 0 bin/release_brew.sh | 0 bin/release_deb.sh | 0 bin/release_docker.sh | 0 bin/release_docs.sh | 0 bin/release_git.sh | 0 bin/release_pip.sh | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/build_git.sh mode change 100644 => 100755 bin/release_brew.sh mode change 100644 => 100755 bin/release_deb.sh mode change 100644 => 100755 bin/release_docker.sh mode change 100644 => 100755 bin/release_docs.sh mode change 100644 => 100755 bin/release_git.sh mode change 100644 => 100755 bin/release_pip.sh diff --git a/bin/build_git.sh b/bin/build_git.sh old mode 100644 new mode 100755 diff --git a/bin/release_brew.sh b/bin/release_brew.sh old mode 100644 new mode 100755 diff --git a/bin/release_deb.sh b/bin/release_deb.sh old mode 100644 new mode 100755 diff --git a/bin/release_docker.sh b/bin/release_docker.sh old mode 100644 new mode 100755 diff --git a/bin/release_docs.sh b/bin/release_docs.sh old mode 100644 new mode 100755 diff --git a/bin/release_git.sh b/bin/release_git.sh old mode 100644 new mode 100755 diff --git a/bin/release_pip.sh b/bin/release_pip.sh old mode 100644 new mode 100755