Skip to content
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
88 changes: 0 additions & 88 deletions .github/workflows/snapshot-bundle.yml

This file was deleted.

82 changes: 81 additions & 1 deletion .github/workflows/snapshot-module-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ on:
type: string
required: false
default: ''
version-numbers:
description: 'The pending version/tag info, as a JSON object'
type: string
required: false
default: '{}'

permissions:
issues: write
Expand All @@ -38,6 +43,11 @@ env:
GH_REPO: ${{ github.repository }}
GH_HOST: github.com
GH_TOKEN: ${{ secrets.GH_PAT || github.token }}
BASELINE: ${{ fromJSON(inputs.version-numbers).baseline }}
MAJOR_VERSION: ${{ fromJSON(inputs.version-numbers).major }}
MINOR_VERSION: ${{ fromJSON(inputs.version-numbers).minor }}
REVISION: ${{ fromJSON(inputs.version-numbers).rev }}
BUILD_NUMBER: ${{ fromJSON(inputs.version-numbers).build }}

jobs:
snapshot-module:
Expand Down Expand Up @@ -92,6 +102,60 @@ jobs:
# There must not be conflicts, if there are, then this cannot be done automatically.
git merge --no-ff -F ${RUNNER_TEMP}/commit-msg.txt ${DEV_BRANCH}

- name: Find version header file(s)
run: >
find . -type f -name '*version.h' |
grep -v 'ut-stubs' |
tee "${RUNNER_TEMP}/version-files.list"

- name: Update Baseline
if: env.BASELINE != ''
run: >
cat "${RUNNER_TEMP}/version-files.list" |
xargs -r sed -i -r -e "s/^(#define \S+_BASELINE\s+).*$/\1\"${BASELINE}\"/"

- name: Update Major Version
if: env.MAJOR_VERSION != ''
run: >
cat "${RUNNER_TEMP}/version-files.list" |
xargs -r sed -i -r -e "s/^(#define \S+_MAJOR_VERSION\s+).*$/\1${MAJOR_VERSION}/"

- name: Update Minor Version
if: env.MINOR_VERSION != ''
run: >
cat "${RUNNER_TEMP}/version-files.list" |
xargs -r sed -i -r -e "s/^(#define \S+_MINOR_VERSION\s+).*$/\1${MINOR_VERSION}/"

- name: Update Revision
if: env.REVISION != ''
run: >
cat "${RUNNER_TEMP}/version-files.list" |
xargs -r sed -i -r -e "s/^(#define \S+_REVISION\s+).*$/\1${REVISION}/"

- name: Update Build Number
if: env.BUILD_NUMBER != ''
run: >
cat "${RUNNER_TEMP}/version-files.list" |
xargs -r sed -i -r -e "s/^(#define \S+_BUILD_NUMBER\s+).*$/\1${BUILD_NUMBER}/"

- name: Check for changes
if: inputs.version-numbers != ''
env:
VERSION_NUMBERS: ${{ inputs.version-numbers }}
run: |
cat << EOF > ${RUNNER_TEMP}/commit-msg.txt
IC: $(date +%Y-%m-%d) version update

Automatically generated version number update
EOF
echo "${VERSION_NUMBERS}" | jq . | grep '^ ' >> ${RUNNER_TEMP}/commit-msg.txt
git status
if ! git diff --quiet; then
git commit -a -F ${RUNNER_TEMP}/commit-msg.txt
else
echo "No differences found, no commit needed"
fi

- name: Push IC branch
run: |
# Do not force-push direct to the base branch
Expand All @@ -103,6 +167,18 @@ jobs:
fi
git push origin "${FORCE_FLAG}${IC_BRANCH}"

# Note that "gh pr create" will fail if a PR already exists
- name: Check for existing pull request
if: env.IC_BRANCH != env.BASE_BRANCH
run: |
gh pr list --base "${BASE_BRANCH}" --head "${IC_BRANCH}" --json number,title > ${RUNNER_TEMP}/pull-request.json
if [ "$(jq length ${RUNNER_TEMP}/pull-request.json)" -gt 0 ]; then
echo "Found existing PR:"
cat ${RUNNER_TEMP}/pull-request.json
else
rm ${RUNNER_TEMP}/pull-request.json
fi

- name: Create PR
if: env.IC_BRANCH != env.BASE_BRANCH
env:
Expand All @@ -116,4 +192,8 @@ jobs:
else
LABEL_OPTS="-l ${PR_LABEL_IN}"
fi
gh pr create -R "${GH_REPO}" -a "${GH_ACTOR}" -B "${BASE_BRANCH}" -H "${IC_BRANCH}" --title "${DATE_TAG} development snapshot" ${LABEL_OPTS} -F "${RUNNER_TEMP}/commit-msg.txt"
if [ -e ${RUNNER_TEMP}/pull-request.json ]; then
echo "Pull request already exists: ${{ github.server_url }}/${GH_REPO}/pull/$(jq '.[0].number' ${RUNNER_TEMP}/pull-request.json)"
else
gh pr create -R "${GH_REPO}" -a "${GH_ACTOR}" -B "${BASE_BRANCH}" -H "${IC_BRANCH}" --title "${DATE_TAG} development snapshot" ${LABEL_OPTS} -F "${RUNNER_TEMP}/commit-msg.txt"
fi