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

Fixing release workflow #256

Merged
merged 3 commits into from
Jun 27, 2022
Merged
Changes from 2 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
51 changes: 27 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,60 +37,63 @@ jobs:
path: cdn

- name: Prepare version number
id: prepare
working-directory: app-frontend
run: |
echo Clone, copy, commit and push to Altinn-CDN
CURRENT_VERSION=`git describe --abbrev=0 --tags 2>/dev/null`
CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })
APP_MAJOR=${CURRENT_VERSION_PARTS[0]:1}
APP_MINOR=${CURRENT_VERSION_PARTS[1]}
APP_PATCH=${CURRENT_VERSION_PARTS[2]}
echo altinn-app-frontend version: $APP_MAJOR.$APP_MINOR.$APP_PATCH
AUTHOR_FULL=$(git log -1 | grep Author)
AUTHOR_NAME=$(git log -1 | grep Author | cut -d' ' -f2)
AUTHOR_EMAIL=$(git log -1 | grep Author | cut -d' ' -f3 | cut -d'<' -f2 | cut -d'>' -f1)
COMMIT_ID=$(git rev-parse HEAD~0)
echo ::set-output name=APP_MAJOR::${CURRENT_VERSION_PARTS[0]:1}
echo ::set-output name=APP_MINOR::${CURRENT_VERSION_PARTS[1]}
echo ::set-output name=APP_PATCH::${CURRENT_VERSION_PARTS[2]}
Copy link
Member

@tjololo tjololo Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider if this step should have an output ala APP_FULL_VERSION since we have many uses where we combine alle of these. This would in my opinion make the rest of the workflow more readable.

echo ::set-output name=APP_FULL_VERSION::${APP_MAJOR}.${APP_MINOR}.${APP_PATCH}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart! I replaced those, as well as those using MAJOR.MINOR, so now there's no more double or triple variable reads on one line.

echo ::set-output name=AUTHOR_FULL::$(git log -1 | grep Author)
echo ::set-output name=AUTHOR_NAME::$(git log -1 | grep Author | cut -d' ' -f2)
echo ::set-output name=AUTHOR_EMAIL::$(git log -1 | grep Author | cut -d' ' -f3 | cut -d'<' -f2 | cut -d'>' -f1)
echo ::set-output name=COMMIT_ID::$(git rev-parse HEAD~0)
git log -1 | grep -Ev "commit|Author|Date" > ./../commitmsg.txt

- name: Copy version
working-directory: app-frontend
if: "!github.event.release.prerelease"
run: |
echo altinn-app-frontend version: ${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}
cd ..
echo Copy Major Version
mkdir -p ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR/altinn-app-frontend.css
mkdir -p ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}/altinn-app-frontend.css
echo Copy Minor Version
mkdir -p ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR/altinn-app-frontend.css
mkdir -p ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}/altinn-app-frontend.css
echo Copy Patch
mkdir -p ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR.$APP_PATCH
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR.$APP_PATCH/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR.$APP_PATCH/altinn-app-frontend.css
mkdir -p ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}/altinn-app-frontend.css

- name: Copy version (pre-release)
working-directory: app-frontend
if: "github.event.release.prerelease"
run: |
echo altinn-app-frontend version: ${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}
cd ..
echo Copy Patch
mkdir -p ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR.$APP_PATCH
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR.$APP_PATCH/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/$APP_MAJOR.$APP_MINOR.$APP_PATCH/altinn-app-frontend.css
mkdir -p ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this path correct? It looks the same as the one in the previous step (line 70). Should it be in a prerelease directory or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it possibly should. The thinking in #179 was to add preliminary support for prereleases, or, at least not overwrite the major version if someone checks that box. We could (and should) think this through some more before we go ahead with releasing preview versions en-masse. Right now we're releasing from main, so if we were to release (for example) `v3.45.0-preview1` from a certain feature-branch, there's no guarantee the proper v3.45.0 won't be released without the features in that feature-branch.

And per your suggestion, if we introduce a prerelease folder, that would also complicate the list of versions generated in #179 - and thus it would complicate #8562.

I'm open to any suggestions, but right now it's most important that checking the "this is a prerelease" checkbox doesn't just run the regular release workflow (which overwrites the major version).

Copy link
Contributor

@haakemon haakemon Jul 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the reply on this (github notifications and I arent best friends 😅)

But it seems like we are overwriting the current patch version on prerelease releases with the current workflow? Or am I misunderstanding?

I am misunderstanding 🙂 We will anyway increase the patch version number on prerelease, so in effect we will get new patch versions, but minor and major will not be modified.

I think the current approach is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the huddle; no, as long as each new release has its own unique patch version, this overwrites nothing.

cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.js ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}/altinn-app-frontend.js
cp -fr ./app-frontend/src/altinn-app-frontend/dist/altinn-app-frontend.css ./cdn/toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}/altinn-app-frontend.css

- name: Copy patch version and commit to CDN
working-directory: cdn
run: |
echo altinn-app-frontend version: ${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}
cd toolkits/altinn-app-frontend
ls -1 | grep --perl-regexp '^[\d\.]+(-[a-z]+)?$' | sort --version-sort | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' > index.json
cd ../..
git config --global user.email "$AUTHOR_EMAIL"
git config --global user.name "$AUTHOR_NAME"
git config --global user.email "${{ steps.prepare.outputs.AUTHOR_EMAIL }}"
git config --global user.name "${{ steps.prepare.outputs.AUTHOR_NAME }}"
git add .
echo "$AUTHOR_FULL updated altinn-app-frontend to $APP_MAJOR.$APP_MINOR.$APP_PATCH" > ./../commit1.txt
echo "based on commit https://github.com/Altinn/altinn-studio/commit/$COMMIT_ID" > ./../commit2.txt
echo "${{ steps.prepare.outputs.AUTHOR_FULL }} updated altinn-app-frontend to ${{ steps.prepare.outputs.APP_MAJOR }}.${{ steps.prepare.outputs.APP_MINOR }}.${{ steps.prepare.outputs.APP_PATCH }}" > ./../commit1.txt
echo "based on commit https://github.com/Altinn/app-frontend-react/commit/${{ steps.prepare.outputs.COMMIT_ID }}" > ./../commit2.txt
cat ./../commit1.txt ./../commit2.txt ./../commitmsg.txt > ./../commit.txt
cat ./../commit.txt
git commit -F ./../commit.txt
Expand Down