diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2a5b77f1..de381406 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -22,20 +22,11 @@ jobs: with: fetch-depth: 0 - - name: Setup git - run: ./scripts/setup_git.sh - env: - GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} - GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} - - - name: Clone the existing SDK - run: ./scripts/clone_sdk.sh - env: - GITHUB_ORG_ID: ${{ secrets.JS_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.JS_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.JS_SDK_SSH_KEY }} - SDK_PATH: clients/fga-js-sdk - KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}} + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + repository: openfga/js-sdk + path: clients/fga-js-sdk - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -44,14 +35,15 @@ jobs: run: make test-client-js - name: Check for SDK changes - run: ./scripts/commit_push_changes.sh - env: - SDK_PATH: clients/fga-js-sdk - DRY_RUN: 1 - TAGGING_DISABLE: 1 - GITHUB_ORG_ID: ${{ secrets.JS_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.JS_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.JS_SDK_SSH_KEY }} + run: | + cd clients/fga-js-sdk + if $(git status | grep -q "nothing to commit"); then + echo "CLEAN: no changes found" + exit 0 + fi + echo "DIRTY: changes found" + git status + git diff build-and-test-go-sdk: runs-on: ubuntu-latest @@ -60,21 +52,11 @@ jobs: with: fetch-depth: 0 - - name: Setup git - run: ./scripts/setup_git.sh - env: - GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} - GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} - - - name: Clone the existing SDK - run: ./scripts/clone_sdk.sh - env: - GITHUB_ORG_ID: ${{ secrets.GO_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.GO_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.GO_SDK_SSH_KEY }} - SDK_PATH: clients/fga-go-sdk - GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=$tmpdir/known_hosts" - KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}} + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + repository: openfga/go-sdk + path: clients/fga-go-sdk - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -83,14 +65,15 @@ jobs: run: make test-client-go - name: Check for SDK changes - run: ./scripts/commit_push_changes.sh - env: - SDK_PATH: clients/fga-go-sdk - DRY_RUN: 1 - TAGGING_DISABLE: 1 - GITHUB_ORG_ID: ${{ secrets.GO_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.GO_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.GO_SDK_SSH_KEY }} + run: | + cd clients/fga-go-sdk + if $(git status | grep -q "nothing to commit"); then + echo "CLEAN: no changes found" + exit 0 + fi + echo "DIRTY: changes found" + git status + git diff build-and-test-dotnet-sdk: runs-on: ubuntu-latest @@ -99,20 +82,11 @@ jobs: with: fetch-depth: 0 - - name: Setup git - run: ./scripts/setup_git.sh - env: - GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} - GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} - - - name: Clone the existing SDK - run: ./scripts/clone_sdk.sh - env: - GITHUB_ORG_ID: ${{ secrets.DOTNET_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.DOTNET_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.DOTNET_SDK_SSH_KEY }} - SDK_PATH: clients/fga-dotnet-sdk - KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}} + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + repository: openfga/dotnet-sdk + path: clients/fga-dotnet-sdk - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -121,14 +95,16 @@ jobs: run: make test-client-dotnet - name: Check for SDK changes - run: ./scripts/commit_push_changes.sh - env: - SDK_PATH: clients/fga-dotnet-sdk - DRY_RUN: 1 - TAGGING_DISABLE: 1 - GITHUB_ORG_ID: ${{ secrets.DOTNET_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.DOTNET_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.DOTNET_SDK_SSH_KEY }} + run: | + cd clients/fga-dotnet-sdk + if $(git status | grep -q "nothing to commit"); then + echo "CLEAN: no changes found" + exit 0 + fi + echo "DIRTY: changes found" + git status + git diff + build-and-test-python-sdk: runs-on: ubuntu-latest @@ -142,20 +118,11 @@ jobs: with: python-version: '3.10' - - name: Setup git - run: ./scripts/setup_git.sh - env: - GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} - GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} - - - name: Clone the existing SDK - run: ./scripts/clone_sdk.sh - env: - GITHUB_ORG_ID: ${{ secrets.PYTHON_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.PYTHON_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.PYTHON_SDK_SSH_KEY }} - SDK_PATH: clients/fga-python-sdk - KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}} + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + repository: openfga/python-sdk + path: clients/fga-python-sdk - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -165,14 +132,15 @@ jobs: make test-client-python - name: Check for SDK changes - run: ./scripts/commit_push_changes.sh - env: - SDK_PATH: clients/fga-python-sdk - DRY_RUN: 1 - TAGGING_DISABLE: 1 - GITHUB_ORG_ID: ${{ secrets.PYTHON_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.PYTHON_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.PYTHON_SDK_SSH_KEY }} + run: | + cd clients/fga-python-sdk + if $(git status | grep -q "nothing to commit"); then + echo "CLEAN: no changes found" + exit 0 + fi + echo "DIRTY: changes found" + git status + git diff build-and-test-java-sdk: runs-on: ubuntu-latest @@ -188,20 +156,11 @@ jobs: distribution: 'temurin' cache: 'gradle' - - name: Setup git - run: ./scripts/setup_git.sh - env: - GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} - GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} - - - name: Clone the existing SDK - run: ./scripts/clone_sdk.sh - env: - GITHUB_ORG_ID: ${{ secrets.JAVA_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.JAVA_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.JAVA_SDK_SSH_KEY }} - SDK_PATH: clients/fga-java-sdk - KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}} + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + repository: openfga/java-sdk + path: clients/fga-java-sdk - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -211,11 +170,12 @@ jobs: make test-integration-client-java - name: Check for SDK changes - run: ./scripts/commit_push_changes.sh - env: - SDK_PATH: clients/fga-java-sdk - DRY_RUN: 1 - TAGGING_DISABLE: 1 - GITHUB_ORG_ID: ${{ secrets.JAVA_SDK_GITHUB_ORG_ID }} - GITHUB_REPO_ID: ${{ secrets.JAVA_SDK_GITHUB_REPO_ID }} - SSH_KEY: ${{ secrets.JAVA_SDK_SSH_KEY }} + run: | + cd clients/fga-java-sdk + if $(git status | grep -q "nothing to commit"); then + echo "CLEAN: no changes found" + exit 0 + fi + echo "DIRTY: changes found" + git status + git diff diff --git a/README.md b/README.md index 7586cb43..fbf6fc74 100644 --- a/README.md +++ b/README.md @@ -173,24 +173,8 @@ Note: Semgrep will be automatically enabled - there is nothing you need to do fo | Key | Comment | |-----------------------------|-----------------------------------------------------------------------------| -| `KNOWN_HOSTS` | | | `FOSSA_API_KEY` | FOSSA API Key | | `SNYK_TOKEN` | Snyk API Key | -| `GO_SDK_GITHUB_ORG_ID` | The GitHub org for the SDK | -| `GO_SDK_GITHUB_REPO_ID` | The GitHub repo id for the SDK | -| `GO_SDK_SSH_KEY` | The SSH private deploy key for the SDK (Not needed after the SDK is public) | -| `JS_SDK_GITHUB_ORG_ID` | The GitHub org for the SDK | -| `JS_SDK_GITHUB_REPO_ID` | The GitHub repo id for the SDK | -| `JS_SDK_SSH_KEY` | The SSH private deploy key for the SDK (Not needed after the SDK is public) | -| `DOTNET_SDK_GITHUB_ORG_ID` | The GitHub org for the SDK | -| `DOTNET_SDK_GITHUB_REPO_ID` | The GitHub repo id for the SDK | -| `DOTNET_SDK_SSH_KEY` | The SSH private deploy key for the SDK (Not needed after the SDK is public) | -| `PYTHON_SDK_GITHUB_ORG_ID` | The GitHub org for the SDK | -| `PYTHON_SDK_GITHUB_REPO_ID` | The GitHub repo id for the SDK | -| `PYTHON_SDK_SSH_KEY` | The SSH private deploy key for the SDK (Not needed after the SDK is public) | -| `JAVA_SDK_GITHUB_ORG_ID` | The GitHub org for the SDK | -| `JAVA_SDK_GITHUB_REPO_ID` | The GitHub repo id for the SDK | -| `JAVA_SDK_SSH_KEY` | The SSH private deploy key for the SDK (Not needed after the SDK is public) | ## Contributing Please review the [Contributing Guidelines](https://github.com/openfga/.github/blob/main/CONTRIBUTING.md) before sending a PR or opening an issue. diff --git a/scripts/clone_sdk.sh b/scripts/clone_sdk.sh deleted file mode 100755 index 87b37a4c..00000000 --- a/scripts/clone_sdk.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -eval "$(ssh-agent -s)" -tmpdir=$(mktemp -d) - -GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=$tmpdir/known_hosts" -echo "${KNOWN_HOSTS}" > "${tmpdir:?}/known_hosts" - -ssh-add - <<< "${SSH_KEY}"; git clone --depth 1 -b main --single-branch "git@github.com:${GITHUB_ORG_ID}/${GITHUB_REPO_ID}.git" "${SDK_PATH:?}" diff --git a/scripts/commit_push_changes.sh b/scripts/commit_push_changes.sh deleted file mode 100755 index 01ceb325..00000000 --- a/scripts/commit_push_changes.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -cd "${SDK_PATH:?}" || exit - -# 0. Check for changes, exit if non found -echo "Step 00. checking for changed files" -# shellcheck disable=SC2091 -if $(git status | grep -q "nothing to commit"); then - echo "CLEAN: no changes found" - exit 0 -fi - -echo "DIRTY: changes found" -git status -git diff - -# 1. If dry run is enabled, log a message and exit -echo "Step 01. checking for dry run" -if [ -n "$DRY_RUN" ]; then - echo "DIRTY: dry run is enabled, not committing changes" - exit 0 -fi - -# 2. commit -echo "Step 02. committing changed files" -git add . -git commit -m 'build: update with latest changes' - -# 3. push -echo "Step 03. pushing changes" -eval "$(ssh-agent -s)" -tmpdir=$(mktemp -d) - -echo "${KNOWN_HOSTS}" > "${tmpdir:?}/known_hosts" - -ssh-add - <<< "${SSH_KEY}"; GIT_SSH_COMMAND="ssh -vvv -o UserKnownHostsFile=$tmpdir/known_hosts" git push - -# 4. If tagging & publishing the sdk is not enabled, exit -echo "Step 04. checking if tagging is disabled" -if [ -n "$TAGGING_DISABLE" ]; then - echo "Tagging is disabled - skipping" - exit 0 -fi - -# 5. Check if the current version of the SDK has been tagged and released, if not tag and push -echo "Step 05. checking if version has been released" -version=$(cat VERSION.txt) -response_code=$(curl -I "https://github.com/${GITHUB_ORG_ID}/${GITHUB_REPO_ID}/releases/tag/v${version}" -o /dev/null -s -w "%{http_code}\n") - -echo "response_code $response_code, version $version" - -if [[ "$response_code" == "200" ]]; then - echo "Version code already published - skipping" - exit 0 -fi - -# 6. If necessary publish to package manager - e.g. npm or maven, run the publish command -echo "Step 06. publishing" -if [ -n "$PUBLISH_CMD" ]; then - echo "Publishing command not found - skipping" - exit 0 -fi - -echo "Publishing package" -# shellcheck disable=SC2091 -$(PUBLISH_CMD) - -exit 0 diff --git a/scripts/setup_git.sh b/scripts/setup_git.sh deleted file mode 100755 index 5d61f030..00000000 --- a/scripts/setup_git.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -git config --global user.name "${GIT_USER_NAME}" -git config --global user.email "${GIT_USER_EMAIL}" diff --git a/scripts/setup_gpg_key.sh b/scripts/setup_gpg_key.sh deleted file mode 100755 index aa1fe74f..00000000 --- a/scripts/setup_gpg_key.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -if [ -z "$GPG_SECRET_KEY" ]; then - echo "GPG Key not found - skipping" - exit 0 -fi - -echo "Importing GPG Key" -echo -n "$GPG_SECRET_KEY" | base64 --decode | gpg --import