From fb8b495ad54bd70434d4fdd9a0a157bfdfb4f91e Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Tue, 23 Jan 2024 23:41:05 +0100 Subject: [PATCH] add my old scripts dir --- README.md | 2 ++ scripts/publish.sh | 29 +++++++++++++++++++++++++++++ scripts/release.sh | 24 ++++++++++++++++++++++++ scripts/set_all_versions.sh | 6 ++++++ 4 files changed, 61 insertions(+) create mode 100755 scripts/publish.sh create mode 100755 scripts/release.sh create mode 100755 scripts/set_all_versions.sh diff --git a/README.md b/README.md index b395ac7..919d923 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ for additional platforms such as GitHub and GitLab. * [Original Repository](https://git.cscherr.de/PlexSheep/Autocrate) * [GitHub Mirror](https://github.com/PlexSheep/Autocrate) +Take a look at the [scripts](./scripts) directory! [publish.sh](scripts/publish.sh) +and [release.sh](scripts/release.sh) are exactly what I'm trying to get rid of. ## Features diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..2187a89 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e +cargo check --all-features +echo ">>>>>>>> SELECT A NEW VERSION" +cargo ws version --no-git-commit +NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1') +bash scripts/set_all_versions.sh $NEW_VERSION +git add -A +git commit -m "Release v$NEW_VERSION" || (echo ">>>>>>>> COMMIT FAILED OR THERE WAS NOTHING TO COMMIT"; sleep 5) +echo ">>>>>>>> SKIP!!!!!" +cargo ws version --amend +echo ">>>>>>>> PUBLISHING RELEASE FOR REPO" +bash scripts/release.sh +echo ">>>>>>>> PUBLISHING TO CRATES.IO NEXT" +sleep 10 +cargo publish -p libpt-log +cargo publish -p libpt-core +cargo publish -p libpt-bintols +cargo publish -p libpt-math +cargo publish -p libpt-net +cargo publish -p libpt +echo ">>>>>>>> PUBLISHING TO CSCHERR.DE NEXT" +sleep 3 +cargo publish --registry cscherr -p libpt-log +cargo publish --registry cscherr -p libpt-core +cargo publish --registry cscherr -p libpt-bintols +cargo publish --registry cscherr -p libpt-math +cargo publish --registry cscherr -p libpt-net +cargo publish --registry cscherr -p libpt diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..af1d8da --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,24 @@ +#!/bin/bash +TOKEN=$(cat ~/.git-credentials | grep 'git.cscherr.de' | grep -P '(?:)[^:]*(?=@)' -o) +NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1') +VERSION=$(git rev-parse HEAD) +GIT_COMMIT_SHA=$(git rev-parse HEAD) +BODY=" +$(git log $(git describe --tags --abbrev=0)..HEAD --pretty="- %s" --oneline --decorate) +" +USER=PlexSheep +git tag "v$NEW_VERSION-test" || echo "could not tag" +curl -X 'POST' \ + 'https://git.cscherr.de/api/v1/repos/PlexSheep/pt/releases' \ + -H 'accept: application/json' \ + -H "Authorization: token $TOKEN" \ + -H 'Content-Type: application/json' \ + -d '{ + "body": "'"$BODY"'", + "draft": false, + "name": "v'$NEW_VERSION'", + "prerelease": true, + "tag_name": "v'$NEW_VERSION'", + "target_commitish": "'$GIT_COMMIT_SHA'" +}' | python -m json.tool +git push || echo "could not push" diff --git a/scripts/set_all_versions.sh b/scripts/set_all_versions.sh new file mode 100755 index 0000000..0c89340 --- /dev/null +++ b/scripts/set_all_versions.sh @@ -0,0 +1,6 @@ +#!/bin/bash +export NEW_VER=$1 +pwd +sed -i 's/\(^\s*version\)\s*=\s*"\([^"]*\)"$/\1 = "'$NEW_VER'"/g' Cargo.toml +find * -name 'Cargo.toml' -type f \ + -exec sed -i 's/\(libpt.*version\s*=\s*\)"[^"]*"/\1"'$NEW_VER'"/g' Cargo.toml {} +