1111 name : Create release from tag
1212 if : github.repository_owner == 'opencast'
1313 runs-on : ubuntu-latest
14+ outputs :
15+ checksum : ${{ steps.tarball.outputs.checksum }}
16+ tag : ${{ steps.tarball.outputs.tag }}
17+ branch : ${{ steps.tarball.outputs.branch }}
1418 permissions :
1519 contents : write # for the release
1620 pull-requests : write # For the PR in the upstream repo
@@ -33,12 +37,34 @@ jobs:
3337 run : npm run build
3438
3539 - name : create release tarball
40+ id : tarball
3641 working-directory : build
42+ env :
43+ GH_TOKEN : ${{ github.token }}
3744 run : |
3845 tar -czf "../oc-admin-ui-$(git describe --tags).tar.gz" *
39- echo INTERFACE_CHECKSUM=`sha256sum oc-admin-ui-$(git describe --tags).tar.gz | cut -f 1 -d " "` >> $GITHUB_ENV
40- echo INTERFACE_TAG=$(git describe --tags) >> $GITHUB_ENV
41- echo BASE_BRANCH=$(git describe --tags | cut -c 1-4) >> $GITHUB_ENV
46+ echo checksum=`sha256sum ../oc-admin-ui-$(git describe --tags).tar.gz | cut -f 1 -d " "` >> $GITHUB_OUTPUT
47+ echo tag=$(git describe --tags) >> $GITHUB_OUTPUT
48+ while read branchname
49+ do
50+ #branchname looks like 'develop' or 'r/17.x', the describe + cut looks like '17.x', so we prefix with r/
51+ # NB: branchname == develop *should not match* anything so that we fall back to the if case below
52+ if [ "$branchname" != "r/`git describe --tags | cut -f 1 -d -`" ]; then
53+ continue
54+ fi
55+ echo "Base branch is $branchname"
56+ BASE_BRANCH="$branchname"
57+ echo "branch=$branchname" >> $GITHUB_OUTPUT
58+ break
59+ done <<< `gh api \
60+ -H "Accept: application/vnd.github+json" \
61+ -H "X-GitHub-Api-Version: 2022-11-28" \
62+ /repos/${{ github.repository_owner }}/opencast/branches?per_page=100 | \
63+ jq -r '. | map(select(.name | match("r/[0-9]*.x|develop"))) | .[].name'`
64+ if [ -z "${BASE_BRANCH}" ]; then
65+ echo "Base branch is develop"
66+ echo "branch=develop" >> $GITHUB_OUTPUT
67+ fi
4268
4369 - name : create new release
4470 uses : softprops/action-gh-release@v2
@@ -47,14 +73,24 @@ jobs:
4773 fail_on_unmatched_files : true
4874 generate_release_notes : true
4975
76+ upstream-pr :
77+ name : Create upstream PR to incorporate release
78+ if : github.repository_owner == 'opencast'
79+ runs-on : ubuntu-latest
80+ needs : build
81+ permissions :
82+ contents : write # for the release
83+ pull-requests : write # For the PR in the upstream repo
84+
85+ steps :
5086 - name : Prepare git
5187 run : |
5288 git config --global user.name "Release Bot"
5389 git config --global user.email "cloud@opencast.org"
5490
5591 - name : Prepare GitHub SSH key
5692 env :
57- DEPLOY_KEY : ${{ secrets.DEPLOY_KEY }}
93+ DEPLOY_KEY : ${{ secrets.MODULE_PR_DEPLOY_KEY }}
5894 run : |
5995 install -dm 700 ~/.ssh/
6096 echo "${DEPLOY_KEY}" > ~/.ssh/id_ed25519
@@ -63,24 +99,27 @@ jobs:
6399
64100 - name : Clone upstream repository
65101 run : |
66- #This token is an account wide token which allows creation of PRs and pushes.
67- #echo "GH_TOKEN=${{ secrets.ACCESS_TOKEN }}" >> token.txt
68- #gh auth login --with-token < token.txt
69- git clone -b r/$BASE_BRANCH "git@github.com:opencast/opencast.git" ~/opencast
70- cd ~/opencast
71- git checkout -b t/admin-ui-$INTERFACE_TAG
102+ git clone -b ${{ needs.build.outputs.branch }} "git@github.com:${{ github.repository_owner }}/opencast.git" opencast
103+ cd opencast
104+ git checkout -b t/admin-ui-${{ needs.build.outputs.tag }}
72105
73106 - name : Update the admin ui pom file
74- # env:
75- # GH_TOKEN: ${{ github.token }}
107+ working-directory : opencast
76108 run : |
77- cd ~/opencast
78- sed -i "s#<interface.sha256>.*</interface.sha256>#<interface.sha256>$INTERFACE_CHECKSUM</interface.sha256>#" modules/admin-ui-interface/pom.xml
79- sed -i "s#<interface.url>.*</interface.url>#<interface.url>https://github.com/opencast/opencast-admin-interface/releases/download/$INTERFACE_TAG/oc-admin-ui-$INTERFACE_TAG.tar.gz</interface.url>#" modules/admin-ui-interface/pom.xml
109+ sed -i "s#<interface.sha256>.*</interface.sha256>#<interface.sha256>${{ needs.build.outputs.checksum }}</interface.sha256>#" modules/admin-ui-interface/pom.xml
110+ sed -i "s#<interface.url>.*</interface.url>#<interface.url>https://github.com/${{ github.repository_owner }}/opencast-admin-interface/releases/download/${{ needs.build.outputs.tag }}/oc-admin-ui-${{ needs.build.outputs.tag }}.tar.gz</interface.url>#" modules/admin-ui-interface/pom.xml
80111 git add modules/admin-ui-interface/pom.xml
81- git commit -m "Updating admin ui to $INTERFACE_TAG "
82- git push origin t/admin-ui-$INTERFACE_TAG
112+ git commit -m "Updating admin ui to ${{ needs.build.outputs.tag }} "
113+ git push origin t/admin-ui-${{ needs.build.outputs.tag }}
83114 #This token is an account wide token which allows creation of PRs and pushes.
84- echo "${{ secrets.PR_TOKEN }}" > token.txt
115+ echo "${{ secrets.MODULE_PR_TOKEN }}" > token.txt
85116 gh auth login --with-token < token.txt
86- gh pr create --title "Update $BASE_BRANCH Admin UI to $INTERFACE_TAG" --label admin-ui --label maintenance --body "Updating Opencast $BASE_BRANCH Admin UI module to $INTERFACE_TAG" --head=opencast:t/admin-ui-$INTERFACE_TAG --base r/$BASE_BRANCH -R opencast/opencast
117+ gh pr create \
118+ --title "Update ${{ needs.build.outputs.branch }} Admin UI to ${{ needs.build.outputs.tag }}" \
119+ --body "Updating Opencast ${{ needs.build.outputs.branch }} Admin UI module to [${{ needs.build.outputs.tag }}](https://github.com/${{ github.repository_owner }}/opencast-admin-interface/releases/tag/${{ needs.build.outputs.tag }})" \
120+ --head=${{ github.repository_owner }}:t/admin-ui-${{ needs.build.outputs.tag }} \
121+ --base ${{ needs.build.outputs.branch }} \
122+ -R ${{ github.repository_owner }}/opencast
123+ #FIXME: fine grained PATs can't apply labels
124+ #FIXME: classic PATs don't have the permissions because the PR isn't in an opencastproject (the user) repo
125+ #--label admin-ui --label maintenance \
0 commit comments