Skip to content

Commit 8f77f47

Browse files
committed
Adding release automation
1 parent 458a674 commit 8f77f47

2 files changed

Lines changed: 100 additions & 27 deletions

File tree

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
11
on:
2-
push:
3-
tags:
4-
- '*-*-*'
2+
workflow_dispatch:
53

6-
name: Create release draft
4+
name: Create release tag
75

86
jobs:
97
build:
10-
name: Create release from tag
8+
name: Create release tag
119
runs-on: ubuntu-latest
1210
steps:
1311
- name: checkout code
1412
uses: actions/checkout@v4
15-
16-
- name: get node.js
17-
uses: actions/setup-node@v4
1813
with:
19-
node-version: 20
20-
21-
- name: download dependencies
22-
run: npm ci
14+
fetch-depth: 0
2315

24-
- name: build release
25-
env:
26-
PUBLIC_URL: /admin-ui
27-
run: npm run build
16+
- name: prepare git
17+
run: |
18+
git config --global user.email 'cloud@opencast.org'
19+
git config --global user.name 'Release Bot'
2820
29-
- name: create release tarball
30-
working-directory: build
31-
run: tar -czf "../oc-admin-ui-$(date -u +%F).tar.gz" *
32-
33-
- name: create new release
34-
uses: softprops/action-gh-release@v2
35-
with:
36-
files: ./oc-admin-ui-*.tar.gz
37-
draft: true
38-
fail_on_unmatched_files: true
39-
generate_release_notes: true
21+
- name: tag and push
22+
run: |
23+
export TEMP=${{ github.ref_name }}
24+
export TAG=${TEMP#r\/}-`date +%Y-%m-%d`
25+
git tag $TAG
26+
git push origin $TAG
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
on:
2+
workflow_dispatch:
3+
push:
4+
tags:
5+
# CF: 17.x-YYYY-MM-DD
6+
- '*.x-*-*-*'
7+
8+
name: Create release
9+
jobs:
10+
build:
11+
name: Create release from tag
12+
if: github.repository_owner == 'opencast'
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write #for the release
16+
pull-requests: write #For the PR in the upstream repo
17+
18+
steps:
19+
- name: checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: get node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
27+
- name: download dependencies
28+
run: npm ci
29+
30+
- name: build release
31+
env:
32+
PUBLIC_URL: /admin-ui
33+
run: npm run build
34+
35+
- name: create release tarball
36+
working-directory: build
37+
run: |
38+
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
42+
43+
- name: create new release
44+
uses: softprops/action-gh-release@v2
45+
with:
46+
files: oc-admin-ui-*.tar.gz
47+
fail_on_unmatched_files: true
48+
generate_release_notes: true
49+
50+
- name: Prepare git
51+
run: |
52+
git config --global user.name "Release Bot"
53+
git config --global user.email "cloud@opencast.org"
54+
55+
- name: Prepare GitHub SSH key
56+
env:
57+
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
58+
run: |
59+
install -dm 700 ~/.ssh/
60+
echo "${DEPLOY_KEY}" > ~/.ssh/id_ed25519
61+
chmod 600 ~/.ssh/id_ed25519
62+
ssh-keyscan github.com >> ~/.ssh/known_hosts
63+
64+
- name: Clone upstream repository
65+
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
72+
73+
- name: Update the admin ui pom file
74+
#env:
75+
# GH_TOKEN: ${{ github.token }}
76+
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
80+
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
83+
#This token is an account wide token which allows creation of PRs and pushes.
84+
echo "${{ secrets.PR_TOKEN }}" > token.txt
85+
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

0 commit comments

Comments
 (0)