Skip to content

Commit

Permalink
Allow release script to do even more work (#79)
Browse files Browse the repository at this point in the history
* use deno script for updates

* input milestone

* select pull requests

* do not assign milestone if it does not exist

* assign issues and pull requests to milestone

* move issue creation at the end of update

* update deps

* download docs and run generator

* added handlebar-magic call

* separated update docs

* closed todos

* updated docs
  • Loading branch information
kilork authored Feb 13, 2024
1 parent e98c956 commit aa4d27f
Show file tree
Hide file tree
Showing 5 changed files with 1,063 additions and 31 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
If we have `x.y.z` version of `keycloak`, our package version would be `x.y.(z * 100 + v)` there v is a minor
fix version to official `x.y.z` version.

Example: official version `13.0.1` is `13.0.100` for crate version. `13.0.102` means keycloak version `13.0.1` and minor fix version `2`.
Example: official version `13.0.1` is `13.0.100` for crate version. `13.0.102` means keycloak version `13.0.1` and minor fix version `2`.

## Update

To update current version use provided [update.ts](./update.ts) `deno` script:

```sh
deno run --allow-env=KEYCLOAK_RUST_VERSION,KEYCLOAK_VERSION,KEYCLOAK_RUST_MAJOR_VERSION --allow-read=Cargo.toml --allow-write=Cargo.toml,docs/rest-api.html,src/types.rs,src/rest/generated_rest.rs --allow-net=keycloak.org,www.keycloak.org --allow-run=cargo,gh,git update.ts
```
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ If we have `x.y.z` version of `keycloak`, our package version would be `x.y.(z *
fix version to official `x.y.z` version.
Example: official version `13.0.1` is `13.0.100` for crate version. `13.0.102` means keycloak version `13.0.1` and minor fix version `2`.
## Update
To update current version use provided [update.ts](./update.ts) `deno` script:
```sh
deno run --allow-env=KEYCLOAK_RUST_VERSION,KEYCLOAK_VERSION,KEYCLOAK_RUST_MAJOR_VERSION --allow-read=Cargo.toml --allow-write=Cargo.toml,docs/rest-api.html,src/types.rs,src/rest/generated_rest.rs --allow-net=keycloak.org,www.keycloak.org --allow-run=cargo,gh,git update.ts
```
*/

pub mod types;
Expand Down
10 changes: 9 additions & 1 deletion templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ keycloak = "{{ env_var "KEYCLOAK_RUST_MAJOR_VERSION" }}"
If we have `x.y.z` version of `keycloak`, our package version would be `x.y.(z * 100 + v)` there v is a minor
fix version to official `x.y.z` version.

Example: official version `13.0.1` is `13.0.100` for crate version. `13.0.102` means keycloak version `13.0.1` and minor fix version `2`.
Example: official version `13.0.1` is `13.0.100` for crate version. `13.0.102` means keycloak version `13.0.1` and minor fix version `2`.

## Update

To update current version use provided [update.ts](./update.ts) `deno` script:

```sh
deno run --allow-env=KEYCLOAK_RUST_VERSION,KEYCLOAK_VERSION,KEYCLOAK_RUST_MAJOR_VERSION --allow-read=Cargo.toml --allow-write=Cargo.toml,docs/rest-api.html,src/types.rs,src/rest/generated_rest.rs --allow-net=keycloak.org,www.keycloak.org --allow-run=cargo,gh,git update.ts
```
91 changes: 62 additions & 29 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,43 @@

set -e

KEYCLOAK_RUST_VERSION=`grep "version = " Cargo.toml | head -n1 | cut -d"\"" -f 2`
KEYCLOAK_RUST_MAJOR_VERSION=`echo ${KEYCLOAK_RUST_VERSION} | cut -f 1,2 -d"."`
KEYCLOAK_VERSION=`echo ${KEYCLOAK_RUST_MAJOR_VERSION}.$(($(echo ${KEYCLOAK_RUST_VERSION} | cut -f 3 -d".") / 100))`
GITHUB_ISSUE=`git branch --show-current | grep -oh "^\d*"`
LAST_KEYCLOAK_VERSION=$(curl https://www.keycloak.org/ --no-progress-meter -o - | grep "Latest release" | xargs | cut -f3 -d" ")
KEYCLOAK_RUST_VERSION=$(grep "version = " Cargo.toml | head -n1 | cut -d"\"" -f 2)
KEYCLOAK_RUST_MAJOR_VERSION=$(echo ${KEYCLOAK_RUST_VERSION} | cut -f 1,2 -d".")
KEYCLOAK_VERSION=$(echo ${KEYCLOAK_RUST_MAJOR_VERSION}.$(($(echo ${KEYCLOAK_RUST_VERSION} | cut -f 3 -d".") / 100)))

function get_milestone
{
milestone=$1
if [ -z "${milestone}" ]; then
echo "get_milestone: no parameter given, provide milestone!"
exit 1
fi
echo "checking if requested milestone (${milestone}) exists"
output=`gh api \
-H "Accept: application/vnd.github.v3+json" \
repos/kilork/keycloak/milestones?state=all \
--jq '.[].title' `
echo "output: $output"
}

if [ "${LAST_KEYCLOAK_VERSION}" != "${KEYCLOAK_VERSION}" ]; then
echo "version of keycloak (${LAST_KEYCLOAK_VERSION}) is different to project version (${KEYCLOAK_VERSION})"
BRANCH=$(git branch --show-current)
DEF_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
if [ "${BRANCH}" != "${DEF_BRANCH}" ]; then
last_keycloak_major_version=$(echo ${LAST_KEYCLOAK_VERSION} | cut -f 1,2 -d".")
last_keycloak_minor_version=$(echo $(($(echo ${LAST_KEYCLOAK_VERSION} | cut -f 3 -d".") * 100)))
MILESTONE=${last_keycloak_major_version}.${last_keycloak_minor_version}
echo target milestone: $MILESTONE
get_milestone $MILESTONE
exit 1
else
echo "no actions would be performed in non-default branch, running regular update"
fi
fi

GITHUB_ISSUE=$(git branch --show-current | grep -oh "^\d*")

echo "Enter cargo version [${KEYCLOAK_RUST_VERSION}]: \c"
read keycloak_rust_version
Expand All @@ -24,23 +57,23 @@ echo "cargo version: ${KEYCLOAK_RUST_VERSION} rest: ${KEYCLOAK_VERSION} issue: $
echo "Continue [Y]? \c"
read CONFIRM
case "$CONFIRM" in
[Nn]*)
exit 0
;;
*)
[Nn]*)
exit 0
;;
*) ;;
esac

KEYCLOAK_REST_DOCS=https://www.keycloak.org/docs-api/${KEYCLOAK_VERSION}/rest-api/index.html
echo "Download and update docs from ${KEYCLOAK_REST_DOCS} [Y]? \c"
read CONFIRM

case "$CONFIRM" in
[Yy]*|"")
curl ${KEYCLOAK_REST_DOCS} -o docs/rest-api.html
git diff docs/rest-api.html || true
echo "Docs updated."
;;
*) echo "No docs updated."
[Yy]* | "")
curl ${KEYCLOAK_REST_DOCS} -o docs/rest-api.html
git diff docs/rest-api.html || true
echo "Docs updated."
;;
*) echo "No docs updated." ;;
esac

echo Updating documentation...
Expand All @@ -51,16 +84,16 @@ git diff README.md || true
echo "Continue [Y]? \c"
read CONFIRM
case "$CONFIRM" in
[Nn]*)
exit 0
;;
*)
[Nn]*)
exit 0
;;
*) ;;
esac

echo Generating types...
git checkout -- src/types.rs src/rest/generated_rest.rs
cargo run --example gen -- types > src/types2.rs
cargo run --example gen -- rest > src/rest/rest2.rs
cargo run --example gen -- types >src/types2.rs
cargo run --example gen -- rest >src/rest/rest2.rs
mv src/types2.rs src/types.rs
mv src/rest/rest2.rs src/rest/generated_rest.rs
echo Types generated.
Expand All @@ -74,10 +107,10 @@ git diff || true
echo "Commit changes to git [Y]? \c"
read CONFIRM
case "$CONFIRM" in
[Nn]*)
exit 0
;;
*)
[Nn]*)
exit 0
;;
*) ;;
esac

git add .
Expand All @@ -90,10 +123,10 @@ git tag --list -n10 v${KEYCLOAK_RUST_VERSION}
echo "Publish to crates.io [Y]? \c"
read CONFIRM
case "$CONFIRM" in
[Nn]*)
exit 0
;;
*)
[Nn]*)
exit 0
;;
*) ;;
esac

cargo publish
cargo publish
Loading

0 comments on commit aa4d27f

Please sign in to comment.