From f15d0d96cd4fc74343c4d1aba50f0e05632ae83a Mon Sep 17 00:00:00 2001 From: Ute Weiss Date: Fri, 10 Sep 2021 12:13:23 +0200 Subject: [PATCH 1/4] chore: create script to update THIRD_PARTY_NOTICE Signed-off-by: Ute Weiss --- update_notice.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 update_notice.sh diff --git a/update_notice.sh b/update_notice.sh new file mode 100755 index 00000000..24d62971 --- /dev/null +++ b/update_notice.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +UPSTREAM_URL='git@github.com:TNG/momo-scheduler.git' +UPSTREAM_BRANCH=main +NOTICE_FILENAME=THIRD_PARTY_NOTICE + +set -eux + +GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +if [[ ! $GIT_BRANCH =~ $UPSTREAM_BRANCH ]]; then + echo "You do not seem to be on the ${UPSTREAM_BRANCH} branch!" + exit 1 +fi + +if [ -n "$(git status --porcelain)" ]; then + echo "You have local changes!" + exit 1 +fi + +echo "Running ORT analyzer" +docker run -v $(pwd):/project philipssoftware/ort --info analyze -f JSON -i /project -o /project/ort + +echo "Creating ORT report" +docker run -v $(pwd):/project philipssoftware/ort --info report -f StaticHtml,WebApp,Excel,NoticeTemplate,SPDXDocument,GitLabLicensemodel,AsciiDocTemplate,CycloneDx,EvaluatedModel -i /project/ort/analyzer-result.json -o /project/ort + +echo "Committing updated ${NOTICE_FILENAME}" +cp $(pwd)/ort/NOTICE_default $(pwd)/${NOTICE_FILENAME} +git add ${NOTICE_FILENAME} +git commit -s -m "chore: update THIRD_PARTY_NOTICE" From f8569c1583d23ccdb9071a07a4c3efb483bebcbc Mon Sep 17 00:00:00 2001 From: Ute Weiss Date: Fri, 10 Sep 2021 16:32:43 +0200 Subject: [PATCH 2/4] chore: improve scripts, add "update third party notice" workflow Signed-off-by: Ute Weiss --- .github/workflows/update_notice.yml | 16 +++++++++ release.sh | 2 +- update_notice.sh | 54 ++++++++++++++++++++++------- 3 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/update_notice.yml diff --git a/.github/workflows/update_notice.yml b/.github/workflows/update_notice.yml new file mode 100644 index 00000000..7e3cdf8b --- /dev/null +++ b/.github/workflows/update_notice.yml @@ -0,0 +1,16 @@ +name: Update THIRD_PARTY_NOTICE + +on: + push: + branches: + - '*-3rd-party-notice' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Update third party notice + uses: actions/checkout@v2 + - shell: bash + run: ./update_notice.sh --dry-run diff --git a/release.sh b/release.sh index 170a17e4..f59f197b 100755 --- a/release.sh +++ b/release.sh @@ -44,7 +44,7 @@ fi git pull "${UPSTREAM_URL}" "${UPSTREAM_BRANCH}" echo "Checking version in package.json" -if [ ! -n "$(sed -n -e "/\"version\": \"${VERSION}\"/ p" package.json)" ]; then +if [ -z "$(sed -n -e "/\"version\": \"${VERSION}\"/ p" package.json)" ]; then echo "Version in package.json is not $VERSION!" exit 1 fi diff --git a/update_notice.sh b/update_notice.sh index 24d62971..e0cd8743 100755 --- a/update_notice.sh +++ b/update_notice.sh @@ -1,15 +1,30 @@ #!/bin/bash UPSTREAM_URL='git@github.com:TNG/momo-scheduler.git' -UPSTREAM_BRANCH=main -NOTICE_FILENAME=THIRD_PARTY_NOTICE +NOTICE_FILENAME=date.txt #THIRD_PARTY_NOTICE +# default: not dry-run +DRY_RUN=0 set -eux -GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [[ ! $GIT_BRANCH =~ $UPSTREAM_BRANCH ]]; then - echo "You do not seem to be on the ${UPSTREAM_BRANCH} branch!" - exit 1 +for arg in "$@"; do + case $arg in + --dry-run) + DRY_RUN=1 + ;; + *) + printf "***************************\n" + printf "* Error: Invalid argument.*\n" + printf "***************************\n" + exit 1 + esac + shift +done + +RELEASE_BRANCH=$(git rev-parse --abbrev-ref HEAD) +if [[ ! $RELEASE_BRANCH =~ ^v[0-9]*\.[0-9]*\.[0-9]*(-[A-Z0-9]*)?-release ]]; then + echo "You do not seem to be on a release branch!" + # exit 1 fi if [ -n "$(git status --porcelain)" ]; then @@ -17,13 +32,28 @@ if [ -n "$(git status --porcelain)" ]; then exit 1 fi -echo "Running ORT analyzer" -docker run -v $(pwd):/project philipssoftware/ort --info analyze -f JSON -i /project -o /project/ort +if [[ $DRY_RUN = 1 ]]; then + date > $NOTICE_FILENAME +else + echo "Running ORT analyzer" + docker run -v "$(pwd)":/project philipssoftware/ort --info analyze -f JSON -i /project -o /project/ort + + echo "Creating ORT report" + docker run -v "$(pwd)":/project philipssoftware/ort --info report -f StaticHtml,WebApp,Excel,NoticeTemplate,SPDXDocument,GitLabLicensemodel,AsciiDocTemplate,CycloneDx,EvaluatedModel -i /project/ort/analyzer-result.json -o /project/ort -echo "Creating ORT report" -docker run -v $(pwd):/project philipssoftware/ort --info report -f StaticHtml,WebApp,Excel,NoticeTemplate,SPDXDocument,GitLabLicensemodel,AsciiDocTemplate,CycloneDx,EvaluatedModel -i /project/ort/analyzer-result.json -o /project/ort + cp ort/NOTICE_default ${NOTICE_FILENAME} +fi + +echo "Created ${NOTICE_FILENAME}:" +head ${NOTICE_FILENAME} echo "Committing updated ${NOTICE_FILENAME}" -cp $(pwd)/ort/NOTICE_default $(pwd)/${NOTICE_FILENAME} git add ${NOTICE_FILENAME} -git commit -s -m "chore: update THIRD_PARTY_NOTICE" + +if [[ $DRY_RUN = 1 ]]; then + git commit -s -m "chore: update THIRD_PARTY_NOTICE (dry-run)" --dry-run + git push "$UPSTREAM_URL" "$RELEASE_BRANCH" --dry-run +else + git commit -s -m "chore: update THIRD_PARTY_NOTICE" + git push "$UPSTREAM_URL" "$RELEASE_BRANCH" +fi \ No newline at end of file From 8d86efb709d17d89528edf865e75aa45fa8f7be9 Mon Sep 17 00:00:00 2001 From: Ute Weiss Date: Thu, 30 Sep 2021 09:03:53 +0200 Subject: [PATCH 3/4] feat: create and commit THIRD_PARTY_NOTICE directly in workflow Signed-off-by: Ute Weiss --- .github/workflows/update_notice.yml | 22 ++++++++--- update_notice.sh | 59 ----------------------------- 2 files changed, 16 insertions(+), 65 deletions(-) delete mode 100755 update_notice.sh diff --git a/.github/workflows/update_notice.yml b/.github/workflows/update_notice.yml index 7e3cdf8b..57fd5d2f 100644 --- a/.github/workflows/update_notice.yml +++ b/.github/workflows/update_notice.yml @@ -6,11 +6,21 @@ on: - '*-3rd-party-notice' jobs: - build: + update-notice: runs-on: ubuntu-latest - steps: - - name: Update third party notice - uses: actions/checkout@v2 - - shell: bash - run: ./update_notice.sh --dry-run + - uses: actions/checkout@v2 + - name: Update THIRD_PARTY_NOTICE + run: | + echo "*** Running ORT analyzer ***" + docker run -v "$(pwd)":/project philipssoftware/ort --info analyze -f JSON -i /project -o /project/ort + echo "*** Creating ORT report ***" + docker run -v "$(pwd)":/project philipssoftware/ort --info report -f StaticHtml,WebApp,Excel,NoticeTemplate,SPDXDocument,GitLabLicensemodel,AsciiDocTemplate,CycloneDx,EvaluatedModel -i /project/ort/analyzer-result.json -o /project/ort + cp ort/NOTICE_default THIRD_PARTY_NOTICE + - name: Commit THIRD_PARTY_NOTICE + run: | + git config --global user.name 'Ute Weiss' + git config --global user.email 'ute.weiss@tngtech.com' + git add THIRD_PARTY_NOTICE + git commit -sam "chore: update THIRD_PARTY_NOTICE" + git push diff --git a/update_notice.sh b/update_notice.sh deleted file mode 100755 index e0cd8743..00000000 --- a/update_notice.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -UPSTREAM_URL='git@github.com:TNG/momo-scheduler.git' -NOTICE_FILENAME=date.txt #THIRD_PARTY_NOTICE -# default: not dry-run -DRY_RUN=0 - -set -eux - -for arg in "$@"; do - case $arg in - --dry-run) - DRY_RUN=1 - ;; - *) - printf "***************************\n" - printf "* Error: Invalid argument.*\n" - printf "***************************\n" - exit 1 - esac - shift -done - -RELEASE_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [[ ! $RELEASE_BRANCH =~ ^v[0-9]*\.[0-9]*\.[0-9]*(-[A-Z0-9]*)?-release ]]; then - echo "You do not seem to be on a release branch!" - # exit 1 -fi - -if [ -n "$(git status --porcelain)" ]; then - echo "You have local changes!" - exit 1 -fi - -if [[ $DRY_RUN = 1 ]]; then - date > $NOTICE_FILENAME -else - echo "Running ORT analyzer" - docker run -v "$(pwd)":/project philipssoftware/ort --info analyze -f JSON -i /project -o /project/ort - - echo "Creating ORT report" - docker run -v "$(pwd)":/project philipssoftware/ort --info report -f StaticHtml,WebApp,Excel,NoticeTemplate,SPDXDocument,GitLabLicensemodel,AsciiDocTemplate,CycloneDx,EvaluatedModel -i /project/ort/analyzer-result.json -o /project/ort - - cp ort/NOTICE_default ${NOTICE_FILENAME} -fi - -echo "Created ${NOTICE_FILENAME}:" -head ${NOTICE_FILENAME} - -echo "Committing updated ${NOTICE_FILENAME}" -git add ${NOTICE_FILENAME} - -if [[ $DRY_RUN = 1 ]]; then - git commit -s -m "chore: update THIRD_PARTY_NOTICE (dry-run)" --dry-run - git push "$UPSTREAM_URL" "$RELEASE_BRANCH" --dry-run -else - git commit -s -m "chore: update THIRD_PARTY_NOTICE" - git push "$UPSTREAM_URL" "$RELEASE_BRANCH" -fi \ No newline at end of file From 39234d29a9deef7e0289b19f8c826f0c0d645732 Mon Sep 17 00:00:00 2001 From: Ute Weiss Date: Thu, 30 Sep 2021 09:44:26 +0200 Subject: [PATCH 4/4] fix: run update-notice job only on release branches Signed-off-by: Ute Weiss --- .github/workflows/update_notice.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_notice.yml b/.github/workflows/update_notice.yml index 57fd5d2f..27fe2cc3 100644 --- a/.github/workflows/update_notice.yml +++ b/.github/workflows/update_notice.yml @@ -3,7 +3,7 @@ name: Update THIRD_PARTY_NOTICE on: push: branches: - - '*-3rd-party-notice' + - '*-release' jobs: update-notice: