Skip to content

Commit 681af27

Browse files
committed
Simplify the SDK Generate diff workflow
1 parent 0d367e7 commit 681af27

2 files changed

Lines changed: 27 additions & 20 deletions

File tree

.github/workflows/sdk-ci.yaml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,17 @@ jobs:
7373
LOG_LEVEL: '7' # debug
7474
GOGC: 'off'
7575

76+
- name: Identify latest branch
77+
id: latest_branch
78+
run: |
79+
echo "ref=$(./scripts/release-preview-or-main.sh)" >> $GITHUB_OUTPUT
80+
7681
- name: Checkout main branch
7782
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
7883
with:
79-
ref: main
84+
ref: ${{ steps.latest_branch.outputs.ref }}
8085
persist-credentials: false
8186

82-
# re-install cog since the PR and main branch might use different versions.
83-
- name: Setup cog
84-
uses: ./.github/actions/setup-cog
85-
86-
- name: Dry-run release with main branch
87-
run: |
88-
git config --global user.email "cog-ci@grafana.com"
89-
git config --global user.name "cog - CI"
90-
91-
devbox run ./scripts/prepare-release.sh
92-
env:
93-
TERM: 'xterm'
94-
WORKSPACE_PATH: /tmp/foundation-workspace-main
95-
CLEANUP_WORKSPACE: 'no'
96-
SKIP_VALIDATION: 'yes'
97-
LOG_LEVEL: '7' # debug
98-
GOGC: 'off'
99-
10087
- name: Preview diff
10188
run: |
10289
cat <<'EOF' > preview.md
@@ -128,7 +115,7 @@ jobs:
128115
--exclude='pyproject.toml' \
129116
--exclude='package.json' \
130117
--exclude='*.md' \
131-
/tmp/foundation-workspace-main/foundation-sdk/ /tmp/foundation-workspace-current/foundation-sdk/ >> preview.md || true # diff returns 1 if the two targets have differences
118+
./ /tmp/foundation-workspace-current/foundation-sdk/ >> preview.md || true # diff returns 1 if the two targets have differences
132119
133120
cat <<'EOF' >> preview.md
134121
```

scripts/release-preview-or-main.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# Exit on error. Append "|| true" if you expect an error.
4+
set -o errexit
5+
# Exit on error inside any functions or subshells.
6+
set -o errtrace
7+
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
8+
set -o nounset
9+
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump | gzip`
10+
set -o pipefail
11+
12+
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13+
source "${__dir}/libs/git.sh"
14+
15+
release_branch_exists=$(git_has_branch "." "release-preview")
16+
if [ "$release_branch_exists" != "0" ]; then
17+
echo "main"
18+
else
19+
echo 'release-preview'
20+
fi

0 commit comments

Comments
 (0)