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

feat: add parameter for the target branch #23

Merged
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
12 changes: 12 additions & 0 deletions .github/workflows/publish-all-in-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@ on:
type: string
required: true
description: "The version that should be released. "
branch:
type: string
required: false
default: "main"
description: "The branch which to publish. must exist in all repos!"
workflow_call:
inputs:
version:
type: string
required: true
description: "The version that should be released. "
branch:
paullatzelsperger marked this conversation as resolved.
Show resolved Hide resolved
type: string
required: false
default: "main"
description: "The branch which to publish. must exist in all repos!"

# these environment variables will be read by prepare.sh
env:
VERSION: ${{ github.event.inputs.version || inputs.version }}
SOURCE_BRANCH: ${{ github.event.inputs.branch || inputs.branch }}

jobs:
secrets-presence:
Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ on:
version:
description: Semantic Version string to use for this release
required: true
branch:
description: Source ranch from which the version should be created. If omitted, 'main' is used.
required: false
default: "main"

env:
INPUT_VERSION: ${{ github.event.inputs.version || inputs.version }}
INPUT_SOURCE_BRANCH: ${{ github.event.inputs.branch || inputs.branch }}


concurrency:
Expand Down Expand Up @@ -41,6 +46,16 @@ jobs:
id: get-version
run: echo "VERSION=${{ env.INPUT_VERSION }}" >> "$GITHUB_OUTPUT"

Determine-Branch:
# this looks to be necessary because some constructs as "with" are not able to get values from env
runs-on: ubuntu-latest
outputs:
SOURCE_BRANCH: ${{ steps.get-branch.outputs.BRANCH }}
steps:
- name: "Get branch"
id: get-branch
run: echo "SOURCE_BRANCH=${{ env.INPUT_SOURCE_BRANCH }}" >> "$GITHUB_OUTPUT"

Run-All-Tests:
name: "Run tests"
runs-on: ubuntu-latest
Expand All @@ -61,21 +76,23 @@ jobs:
- name: "Run test for ${{ matrix.test-def.repo }}"
run: |
chmod +x ./scripts/github_action.sh
./scripts/github_action.sh "eclipse-edc" "${{ matrix.test-def.repo }}" "${{ matrix.test-def.workflowfile}}" "" "${{ secrets.ORG_GITHUB_BOT_USER }}" "${{ secrets.ORG_GITHUB_BOT_TOKEN }}"
./scripts/github_action.sh "eclipse-edc" "${{ matrix.test-def.repo }}" "${{ matrix.test-def.workflowfile}}" "" "${{ secrets.ORG_GITHUB_BOT_USER }}" "${{ secrets.ORG_GITHUB_BOT_TOKEN }}" "${{ env.INPUT_SOURCE_BRANCH }}"

Publish-Components:
needs: [ Determine-Version, Run-All-Tests ]
uses: eclipse-edc/Release/.github/workflows/publish-all-in-one.yaml@main
needs: [ Determine-Version, Determine-Branch, Run-All-Tests ]
uses: ./.github/workflows/publish-all-in-one.yaml
with:
version: ${{ needs.Determine-Version.outputs.VERSION }}
branch: "${{ needs.Determine-Branch.outputs.SOURCE_BRANCH }}"
secrets: inherit

Release-Components:
name: "Release Components"
runs-on: ubuntu-latest
needs: [ Determine-Version, Publish-Components ]
needs: [Secrets-Presence, Determine-Version, Determine-Branch, Publish-Components ]
if: |
needs.Secrets-Presence.outputs.HAS_GH_PAT
needs.Secrets-Presence.outputs.HAS_GH_PAT &&
needs.Determine-Branch.outputs.SOURCE_BRANCH == 'main'
strategy:
fail-fast: false
max-parallel: 1
Expand Down Expand Up @@ -103,7 +120,7 @@ jobs:

Post-To-Discord:
needs: [ Publish-Components, Release-Components, Determine-Version, Secrets-Presence ]
if: "needs.Secrets-Presence.outputs.HAS_WEBHOOK && always()"
if: needs.Secrets-Presence.outputs.HAS_WEBHOOK && always()
runs-on: ubuntu-latest
steps:
- uses: sarisia/actions-status-discord@v1
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This gradle project prepares the EDC for a full release

## Run

```
SOURCE_BRANCH=<git_source_branch> # this is optional
VERSION=<version number> ./prepare.sh
```
8 changes: 7 additions & 1 deletion prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

set -ve

# if SOURCE_BRANCH is not set, set it to "main"
if [ -z "${SOURCE_BRANCH}" ]; then
echo "SOURCE_BRANCH variable not set, will default to 'main'"
SOURCE_BRANCH="main"
fi

# removes any dash, performs toLower
toVersionCatalogName () {
replacement=""
Expand Down Expand Up @@ -85,7 +91,7 @@ EOF
for component in "${components[@]}"
do
rm -rf "$component"
git clone "https://github.com/eclipse-edc/$component"
git clone -b $SOURCE_BRANCH "https://github.com/eclipse-edc/$component"
done

# if the version variable is set, set it in the various gradle.properties and settings.gradle.kts files, otherwise leave the old version
Expand Down
12 changes: 9 additions & 3 deletions scripts/github_action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ WORKFLOW="$3"
INPUTS="$4"
USER="$5"
PWD="$6"
BRANCH="$7"

if [ "$#" -eq 5 ]; then
# use cURL with a Personal Access Token
echo "Using USER as personal access token for the GitHub API"
PARAMS=(-H "Authorization: Bearer $USER" -H "Accept: application/vnd.github.v3+json")

elif [ "$#" -eq 6 ]; then
elif [ "$#" -ge 6 ]; then
# use basic auth with cUrl
echo "Using USER/PWD authentication for the GitHub API"
PARAMS=(-u "$USER":"$PWD" -H "Accept: application/vnd.github.v3+json")
Expand All @@ -25,17 +26,22 @@ else
echo "INPUTS = json representation of the workflow input"
echo "USER = the username to use for authentication against the GitHub API, or an API token"
echo "PWD = the password of USER. if not specified, USER will be interpreted as token"
echo "BRANCH" = the branch on which to execute the action. Defaults to "main"
exit 1
fi

REPO="$OWNER/$REPO_NAME"
WORKFLOW_PATH="$REPO/actions/workflows/$WORKFLOW"

# run actions on "main" by default
if [ -z "${BRANCH}" ]; then
BRANCH="main"
fi

if [ -z "${INPUTS}" ]; then
TRIGGER_BODY="{\"ref\": \"main\"}"
TRIGGER_BODY="{\"ref\": \"${BRANCH}\"}"
else
TRIGGER_BODY="{\"ref\": \"main\", \"inputs\": ${INPUTS}}"
TRIGGER_BODY="{\"ref\": \"${BRANCH}\", \"inputs\": ${INPUTS}}"
fi

echo "$WORKFLOW_PATH :: $(date) :: Trigger the workflow with ${TRIGGER_BODY}"
Expand Down
Loading