diff --git a/.github/scripts/release-build.sh b/.github/scripts/release-build.sh index 61f10d1..a66154e 100755 --- a/.github/scripts/release-build.sh +++ b/.github/scripts/release-build.sh @@ -17,9 +17,6 @@ local_sdk_version_patch=$(echo $local_sdk_version | cut -d '.' -f 3) new_sdk_version_minor=$(( local_sdk_version_minor + 1 )) new_sdk_version="$local_sdk_version_major.$new_sdk_version_minor.0" -branch_name="autobuild-$new_sdk_version" -git branch -m $branch_name - # Update osc-api version curl --retry 10 -o "${root}/osc_sdk_python/resources/outscale.yaml" "https://raw.githubusercontent.com/outscale/osc-api/refs/tags/${osc_api_version}/outscale.yaml" git add "${root}/osc_sdk_python/resources/outscale.yaml" @@ -30,13 +27,4 @@ for f in "$root/README.md" "$root/osc_sdk_python/VERSION"; do git add "$f" done -uv version $(cat VERSION) - -# Setup git && commit -git config user.name "Outscale Bot" -git config user.email "opensource+bot@outscale.com" -commit_msg="🔖 release: osc-sdk-python v$new_sdk_version - - - SDK update for Outscale API $osc_api_version -" -git commit -sm "$commit_msg" +uv version $(cat osc_sdk_python/VERSION) diff --git a/.github/scripts/release-pr.sh b/.github/scripts/release-pr.sh deleted file mode 100755 index 6848814..0000000 --- a/.github/scripts/release-pr.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/env bash -set -e -osc_api_version=$1 - -if [ -z "$osc_api_version" ]; then - echo "run $0 with version tag as argument, abort." - exit 1 -fi - -if [ -z "$GH_TOKEN" ]; then - echo "GH_TOKEN is missing, abort." - exit 1 -fi - -root=$(cd "$(dirname $0)/../.." && pwd) - -new_sdk_version=$(cat $root/osc_sdk_python/VERSION) -major=$(echo $new_sdk_version | cut -d '.' -f 1) -branch_name="autobuild-$new_sdk_version" - -# https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#create-a-pull-request -result=$(curl -s -X POST -H "Authorization: token $GH_TOKEN" -d "{\"head\":\"$branch_name\",\"base\":\"main\",\"title\":\"SDK v$new_sdk_version\",\"body\":\"Automatic build of SDK v$new_sdk_version version based on Outscale API $osc_api_version\"}" "https://api.github.com/repos/outscale/osc-sdk-python/pulls") - -errors=$(echo $result | jq .errors) - -if [ "$errors" != "null" ]; then - echo "errors while creating pull request, abort." - exit 1 -fi diff --git a/.github/scripts/release-push.sh b/.github/scripts/release-push.sh deleted file mode 100755 index cd6c7cb..0000000 --- a/.github/scripts/release-push.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/env bash -set -e - -root=$(cd "$(dirname $0)/../.." && pwd) -new_sdk_version=$(cat $root/osc_sdk_python/VERSION) -branch_name="autobuild-$new_sdk_version" - -if [ -z "$SSH_PRIVATE_KEY" ]; then - echo "SSH_PRIVATE_KEY is missing, abort." - exit 1 -fi - -echo "$SSH_PRIVATE_KEY" > $root/bot.key -GIT_SSH_COMMAND="ssh -i $root/bot.key" git push -f origin $branch_name diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67075cb..4a6a5b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,5 @@ name: osc-sdk-python release build + on: workflow_dispatch: inputs: @@ -6,25 +7,39 @@ on: description: 'Outscale API version' required: true +permissions: + contents: write + pull-requests: write + id-token: write + jobs: auto-build: environment: auto-build runs-on: ubuntu-24.04 steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + - uses: chainguard-dev/actions/setup-gitsign@main - name: Install uv uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7 - name: Set up Python run: uv python install - - name: Initialize submodules - run: make init - name: Build release run: .github/scripts/release-build.sh ${{ github.event.inputs.api_version }} - - name: push release branch - run: .github/scripts/release-push.sh - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - - name: create pull request - run: .github/scripts/release-pr.sh ${{ github.event.inputs.api_version }} + - name: Get SDK version + id: get-sdk-version + run: | + echo "sdk_version=$(cat osc_sdk_python/VERSION)" >> "$GITHUB_OUTPUT" + - name: Create Pull Request + uses: peter-evans/create-pull-request@v8.1.0 + with: + committer: "Outscale Bot " + author: "Outscale Bot " + commit-message: "🔖 release: osc-sdk-python v${{ env.sdk_version }}" + body: | + Automatic build of SDK v${{ env.sdk_version }} version based on Outscale API ${{ env.api_version }}. + title: "SDK v${{ env.sdk_version }}" + token: "${{ env.token }}" env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + sdk_version: ${{ steps.get-sdk-version.outputs.sdk_version }} + api_version: ${{ github.event.inputs.api_version }} + token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}