-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add release automation #67
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
429018f
ci: add automated release workflow
shubham-sumo e5dd6cd
Potential fix for pull request finding
shubham-sumo 31c3ead
ci: fix copilot comments
shubham-sumo ec79dd6
ci: use latest node version
shubham-sumo 282ff47
ci: try node ci fix
shubham-sumo e613db4
Merge branch 'main' into automated-release
shubham-sumo fe0b1b6
ci: add safeguard
shubham-sumo 80dcbe5
ci: temporarily disable me-south-1 region
shubham-sumo cadcea7
Merge remote-tracking branch 'origin/automated-release' into automate…
shubham-sumo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,161 @@ | ||
| name: Check Upstream Releases | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '7 9 * * 1' | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: "If true, detect releases but don't trigger prepare workflow" | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| language: | ||
| description: "Only check this language (leave empty to check all)" | ||
| required: false | ||
| type: choice | ||
| options: | ||
| - '' | ||
| - java | ||
| - nodejs | ||
| - python | ||
|
|
||
| permissions: | ||
| contents: read | ||
| actions: write | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| check: | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Check for new upstream releases | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| DRY_RUN: ${{ inputs.dry_run || 'false' }} | ||
| FILTER_LANGUAGE: ${{ inputs.language || '' }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| UPSTREAM="https://github.com/open-telemetry/opentelemetry-lambda.git" | ||
|
|
||
| declare -A TAG_PREFIX=( | ||
| [java]="layer-javaagent" | ||
| [nodejs]="layer-nodejs" | ||
| [python]="layer-python" | ||
| ) | ||
|
|
||
| semver_gt() { | ||
| local lhs="$1" rhs="$2" | ||
| if [[ "${lhs}" == "${rhs}" ]]; then | ||
| return 1 | ||
| fi | ||
| local IFS='.' | ||
| read -ra L <<< "${lhs}" | ||
| read -ra R <<< "${rhs}" | ||
| for i in 0 1 2; do | ||
| if (( ${L[$i]:-0} > ${R[$i]:-0} )); then | ||
| return 0 | ||
| elif (( ${L[$i]:-0} < ${R[$i]:-0} )); then | ||
| return 1 | ||
| fi | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| minor_bump() { | ||
| local ver="$1" | ||
| local IFS='.' | ||
| read -ra parts <<< "${ver}" | ||
| echo "${parts[0]}.$(( parts[1] + 1 )).0" | ||
| } | ||
|
|
||
| latest_upstream_tag() { | ||
| local prefix="$1" | ||
| git ls-remote --tags "${UPSTREAM}" "refs/tags/${prefix}/*" \ | ||
| | sed 's|.*refs/tags/||' \ | ||
| | grep -v '\^{}' \ | ||
| | sort -t/ -k2 -V \ | ||
| | tail -1 | ||
| } | ||
|
|
||
| TRIGGERED=() | ||
|
|
||
| LANGUAGES=(java nodejs python) | ||
| if [[ -n "${FILTER_LANGUAGE}" ]]; then | ||
| LANGUAGES=("${FILTER_LANGUAGE}") | ||
| fi | ||
|
|
||
| for LANGUAGE in "${LANGUAGES[@]}"; do | ||
| PREFIX="${TAG_PREFIX[${LANGUAGE}]}" | ||
|
|
||
| echo "--- Checking ${LANGUAGE} (prefix: ${PREFIX}) ---" | ||
|
|
||
| LATEST_UPSTREAM=$(latest_upstream_tag "${PREFIX}") | ||
| if [[ -z "${LATEST_UPSTREAM}" ]]; then | ||
| echo "WARNING: No upstream tags found for ${PREFIX}" | ||
| continue | ||
| fi | ||
| echo "Latest upstream: ${LATEST_UPSTREAM}" | ||
|
|
||
| VERSION_FILE="${LANGUAGE}/version.txt" | ||
| CURRENT_VER=$(grep '^current_version=' "${VERSION_FILE}" | cut -d= -f2-) | ||
| LAST_PROCESSED=$(grep '^upstream_release_tag=' "${VERSION_FILE}" | cut -d= -f2-) | ||
| echo "Current version: ${CURRENT_VER}" | ||
| echo "Last processed upstream: ${LAST_PROCESSED}" | ||
|
|
||
| if [[ -z "${CURRENT_VER}" || -z "${LAST_PROCESSED}" ]]; then | ||
| echo "ERROR: could not read named values from ${VERSION_FILE}" | ||
| continue | ||
| fi | ||
|
|
||
| if [[ "${LATEST_UPSTREAM}" == "${LAST_PROCESSED}" ]]; then | ||
| echo "No new release for ${LANGUAGE}" | ||
| continue | ||
| fi | ||
|
|
||
| UPSTREAM_VER="${LATEST_UPSTREAM#"${PREFIX}/"}" | ||
| PROCESSED_VER="${LAST_PROCESSED#"${PREFIX}/"}" | ||
| if ! semver_gt "${UPSTREAM_VER}" "${PROCESSED_VER}"; then | ||
| echo "Upstream ${UPSTREAM_VER} is not newer than ${PROCESSED_VER}" | ||
| continue | ||
| fi | ||
|
|
||
| echo "New release detected: ${LATEST_UPSTREAM} > ${LAST_PROCESSED}" | ||
|
|
||
| EXISTING_PR=$(gh pr list \ | ||
| --state open \ | ||
| --base main \ | ||
| --json number,headRefName \ | ||
| --jq "map(select(.headRefName | startswith(\"prepare-${LANGUAGE}-v\")))[0].number // empty") | ||
| if [[ -n "${EXISTING_PR}" ]]; then | ||
| echo "Skipping ${LANGUAGE}: open prepare PR #${EXISTING_PR} exists" | ||
| continue | ||
| fi | ||
|
|
||
| NEXT_VER=$(minor_bump "${CURRENT_VER}") | ||
| echo "Version bump: ${CURRENT_VER} -> ${NEXT_VER}" | ||
|
|
||
| if [[ "${DRY_RUN}" == "true" ]]; then | ||
| echo "[DRY RUN] Would trigger release-prepare for ${LANGUAGE} v${NEXT_VER} with tag ${LATEST_UPSTREAM}" | ||
| continue | ||
| fi | ||
|
|
||
| echo "Triggering release-prepare for ${LANGUAGE} v${NEXT_VER}" | ||
| gh workflow run release-prepare.yml \ | ||
| -f language="${LANGUAGE}" \ | ||
| -f version="${NEXT_VER}" \ | ||
| -f otel_lambda_tag="${LATEST_UPSTREAM}" | ||
| TRIGGERED+=("${LANGUAGE}-v${NEXT_VER}") | ||
| done | ||
|
|
||
| if [[ ${#TRIGGERED[@]} -gt 0 ]]; then | ||
| echo "" | ||
| echo "=== Triggered releases ===" | ||
| printf ' %s\n' "${TRIGGERED[@]}" | ||
| else | ||
| echo "" | ||
| echo "=== No release workflows triggered ===" | ||
| fi |
This file contains hidden or 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,80 @@ | ||
| name: Release Finalize | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "Pre-release tag to finalize" | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: release-finalize-${{ inputs.tag }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| finalize: | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Extract release details | ||
| id: parse | ||
| env: | ||
| TAG: ${{ inputs.tag }} | ||
| run: | | ||
| if ! [[ "${TAG}" =~ ^(java|nodejs|python)-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then | ||
| echo "::error::Unexpected release tag: ${TAG}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| LANGUAGE="${BASH_REMATCH[1]}" | ||
| VERSION="${BASH_REMATCH[2]}" | ||
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | ||
| echo "language=${LANGUAGE}" >> "$GITHUB_OUTPUT" | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "release_branch=release-${TAG}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ steps.parse.outputs.tag }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Configure git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email \ | ||
| "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Create release branch | ||
| id: branch | ||
| env: | ||
| RELEASE_BRANCH: ${{ steps.parse.outputs.release_branch }} | ||
| run: | | ||
| if git ls-remote --exit-code --heads origin "${RELEASE_BRANCH}"; then | ||
| echo "Release branch ${RELEASE_BRANCH} already exists" | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| git checkout -b "${RELEASE_BRANCH}" | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Update language README title | ||
| if: steps.branch.outputs.exists != 'true' | ||
| env: | ||
| TAG: ${{ steps.parse.outputs.tag }} | ||
| LANGUAGE: ${{ steps.parse.outputs.language }} | ||
| VERSION: ${{ steps.parse.outputs.version }} | ||
| run: ./ci/release-finalize.sh | ||
|
|
||
| - name: Push release branch | ||
| if: steps.branch.outputs.exists != 'true' | ||
| env: | ||
| TAG: ${{ steps.parse.outputs.tag }} | ||
| LANGUAGE: ${{ steps.parse.outputs.language }} | ||
| RELEASE_BRANCH: ${{ steps.parse.outputs.release_branch }} | ||
| run: | | ||
| git add "${LANGUAGE}/README.md" | ||
| git commit -m "docs: update ${LANGUAGE} README for ${TAG}" | ||
| git push origin "${RELEASE_BRANCH}" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.