Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keycloak Test PR #78

Closed
wants to merge 5 commits into from
Closed
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
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-read=Cargo.toml --allow-write=Cargo.toml --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
Loading