-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c306bd
commit 4f44b2f
Showing
10 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "maven" | ||
directory: "/" | ||
target-branch: "main" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
exit_code=0 | ||
if [ -z "$OSC_ACCESS_KEY" ]; then | ||
echo "OSC_ACCESS_KEY var is not set, please fix" | ||
exit_code=1 | ||
fi | ||
if [ -z "$OSC_SECRET_KEY" ]; then | ||
echo "OSC_SECRET_KEY var is not set, please fix" | ||
exit_code=1 | ||
fi | ||
if [ -z "$OSC_REGION" ]; then | ||
echo "OSC_REGION var is not set, please fix" | ||
exit_code=1 | ||
fi | ||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/env bash | ||
set -e | ||
|
||
root=$(cd "$(dirname $0)/../.." && pwd) | ||
if [ -e "$root/.auto-release-abort" ]; then | ||
echo "previous step triggered stop, abort" | ||
exit 0 | ||
fi | ||
github_url="https://api.github.com/repos/outscale/osc-api/releases" | ||
|
||
if [ -z "$GH_TOKEN" ]; then | ||
echo "GH_TOKEN is missing, abort." | ||
exit 1 | ||
fi | ||
|
||
osc_api_last_release=$(curl -s -H "Authorization: token $GH_TOKEN" $github_url | jq ".[] | select(.prerelease == false) | select(.draft == false) | .tag_name" | sort -r --version-sort | head -n 1 | cut -f 2 -d '"') | ||
local_api_version=$(cat $root/api_version) | ||
|
||
echo "last API version used: $local_api_version" | ||
echo "last available version: $osc_api_last_release" | ||
|
||
if [[ "$local_api_version" = "$osc_api_last_release" ]]; then | ||
echo "no update needed, exiting" | ||
touch "$root/.auto-release-abort" | ||
exit 0 | ||
fi | ||
|
||
echo "$osc_api_last_release" > $root/api_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/env bash | ||
set -e | ||
|
||
root=$(cd "$(dirname $0)/../.." && pwd) | ||
if [ -e "$root/.auto-release-abort" ]; then | ||
echo "previous step triggered stop, abort" | ||
exit 0 | ||
fi | ||
# build new version number | ||
local_sdk_version=$(cat $root/sdk_version) | ||
local_sdk_version_major=$(echo $local_sdk_version | cut -d '.' -f 1) | ||
local_sdk_version_minor=$(echo $local_sdk_version | cut -d '.' -f 2) | ||
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 | ||
|
||
echo "$new_sdk_version" > $root/sdk_version | ||
|
||
# build release notes | ||
new_api_version=$(cat $root/api_version) | ||
release_notes="# $new_sdk_version | ||
- SDK update for Outscale API v$new_api_version | ||
" | ||
echo "$release_notes$(cat $root/changelog.md)" > $root/changelog.md | ||
|
||
# generate SDK | ||
cd "$root" | ||
make gen | ||
|
||
# setup git && commit | ||
git config user.name "Outscale Bot" | ||
git config user.email "[email protected]" | ||
for f in src dist; do | ||
git add $f || true | ||
done | ||
git commit -asm "osc-sdk-java v$new_sdk_version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/env bash | ||
set -e | ||
|
||
root=$(cd "$(dirname $0)/../.." && pwd) | ||
if [ -e "$root/.auto-release-abort" ]; then | ||
echo "previous step triggered stop, abort" | ||
exit 0 | ||
fi | ||
# build new version number | ||
local_sdk_version=$(cat $root/sdk_version) | ||
local_sdk_version_major=$(echo $local_sdk_version | cut -d '.' -f 1) | ||
local_sdk_version_minor=$(echo $local_sdk_version | cut -d '.' -f 2) | ||
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" | ||
|
||
if [ -z "$GH_TOKEN" ]; then | ||
echo "GH_TOKEN is missing, abort." | ||
exit 1 | ||
fi | ||
|
||
result=$(curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/repos/outscale/osc-sdk-java/pulls" | jq ".[] | select(.title == \"SDK v$new_sdk_version\") | .title") | ||
|
||
if [ ! -z "$result" ]; then | ||
echo "Pull request seems to alread exist, abort." | ||
touch "$root/.auto-release-abort" | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/env bash | ||
set -e | ||
|
||
root=$(cd "$(dirname $0)/../.." && pwd) | ||
if [ -e "$root/.auto-release-abort" ]; then | ||
echo "previous step triggered stop, abort" | ||
exit 0 | ||
fi | ||
new_sdk_version=$(cat $root/sdk_version) | ||
branch_name="autobuild-$new_sdk_version" | ||
osc_api_version="$(cat $root/api_version)" | ||
|
||
if [ -z "$GH_TOKEN" ]; then | ||
echo "GH_TOKEN is missing, abort." | ||
exit 1 | ||
fi | ||
|
||
# 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 v$osc_api_version\"}" "https://api.github.com/repos/outscale/osc-sdk-java/pulls") | ||
|
||
errors=$(echo $result | jq .errors) | ||
|
||
if [ "$errors" != "null" ]; then | ||
echo $errors | ||
echo "errors while creating pull request, abort." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/env bash | ||
set -e | ||
|
||
root=$(cd "$(dirname $0)/../.." && pwd) | ||
if [ -e "$root/.auto-release-abort" ]; then | ||
echo "previous step triggered stop, abort" | ||
exit 0 | ||
fi | ||
new_sdk_version=$(cat $root/sdk_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: osc-sdk-java release build | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
api_version: | ||
description: 'Outscale API version' | ||
required: true | ||
|
||
jobs: | ||
auto-build: | ||
environment: auto-build | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
cache: 'maven' | ||
- name: Write Outscale API version to use | ||
run: echo "${{ github.event.inputs.api_version }}" > api_version | ||
- name: check for release duplicate | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: make release-check-duplicate | ||
- name: auto-generate release | ||
run: make release-build | ||
- name: push release branch | ||
run: make release-push | ||
env: | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | ||
- name: create pull request | ||
run: make release-pr | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Credential Scanner | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
cred-scan: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Scan credentials | ||
uses: outscale-dev/cred-scan@main | ||
with: | ||
scan_path: "./" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: pull-request | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
jobs: | ||
reuse-test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Reuse specification test | ||
run: make reuse-test | ||
examples-test: | ||
environment: eu-west-2 | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
cache: 'maven' | ||
- name: Example tests | ||
env: | ||
OSC_ACCESS_KEY: ${{ secrets.OSC_ACCESS_KEY }} | ||
OSC_SECRET_KEY: ${{ secrets.OSC_SECRET_KEY }} | ||
OSC_REGION: ${{ secrets.OSC_REGION }} | ||
run: make examples-test | ||
regeneration-test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
cache: 'maven' | ||
- name: SDK re-generation test | ||
run: make regen-test | ||
dependabot-auto-merge: | ||
needs: [reuse-test, examples-test, regeneration-test] | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
steps: | ||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/[email protected] | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
- name: Auto-merge | ||
run: gh pr merge --auto --rebase "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |