@@ -6,9 +6,12 @@ name: Publish Docs Workflow
66on :
77 push :
88 branches :
9- - master
9+ - master
1010 workflow_dispatch :
1111
12+ env :
13+ REPO_OWNER : " omec-project"
14+
1215jobs :
1316 validate :
1417 runs-on : ubuntu-latest
2831 echo "$files"
2932 fi
3033
34+ # NOTE: Action to tag repo, publish images/documents only enabled for "omec-project"
35+ # CAUTION: Other actions depend on this name "tag-github"
36+ tag-github :
37+ runs-on : ubuntu-latest
38+ if : github.repository_owner == env.REPO_OWNER
39+ outputs :
40+ changed : ${{ steps.version-change.outputs.changed }}
41+ version : ${{ steps.version-change.outputs.version }}
42+ steps :
43+ - uses : actions/checkout@v4
44+ with :
45+ fetch-depth : 0
46+
47+ - name : Get changes
48+ id : version-file
49+ run : |
50+ if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep VERSION; then
51+ echo "changed=true" >> $GITHUB_OUTPUT
52+ else
53+ echo "VERSION file was not changed"
54+ fi
55+
56+ - name : Validate change in version file
57+ id : version-change
58+ if : steps.version-file.outputs.changed == 'true'
59+ run : |
60+ version=$(cat VERSION)
61+ echo "version=$version"
62+ validate="^[0-9]+\.[0-9]+\.[0-9]+$"
63+ if [[ $version =~ $validate ]]; then
64+ echo "changed=true" >> $GITHUB_OUTPUT
65+ echo "version=$version" >> $GITHUB_OUTPUT
66+ else
67+ echo "Version change not for release"
68+ fi
69+
70+ - name : Create release using REST API
71+ if : steps.version-change.outputs.changed == 'true'
72+ run : |
73+ curl -L \
74+ -X POST \
75+ -H "Accept: application/vnd.github+json" \
76+ -H "Authorization: Bearer ${{ secrets.GH_OMEC_PAT }}" \
77+ -H "X-GitHub-Api-Version: 2022-11-28" \
78+ https://api.github.com/repos/${{ github.repository }}/releases \
79+ -d '{
80+ "tag_name": "v${{ steps.version-change.outputs.version }}",
81+ "target_commitish": "${{ github.event.repository.default_branch }}",
82+ "name": "v${{ steps.version-change.outputs.version }}",
83+ "draft": false,
84+ "prerelease": false,
85+ "generate_release_notes": true
86+ }'
87+
88+ update-version :
89+ runs-on : ubuntu-latest
90+ needs : tag-github
91+ if : needs.tag-github.outputs.changed == 'true'
92+ steps :
93+ - uses : actions/checkout@v4
94+
95+ - name : Increment version
96+ run : |
97+ version=${{ needs.tag-github.outputs.version }}
98+ IFS='.' read -r major minor patch <<< "$version"
99+ minor_update=$((minor+1))
100+ NEW_VERSION="$major.$minor_update.$patch-dev"
101+ echo $NEW_VERSION > VERSION
102+ echo "Updated version: $NEW_VERSION"
103+
104+ - name : Create Pull Request
105+ uses : peter-evans/create-pull-request@v6
106+ with :
107+ token : ${{ secrets.GH_OMEC_PAT }}
108+ commit-message : Update version
109+ committer : github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
110+ author : ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
111+ signoff : false
112+ branch : version-update
113+ delete-branch : true
114+ title : Update version
115+ body : |
116+ Update VERSION file
117+ add-paths : |
118+ VERSION
119+
31120 publish :
32121 runs-on : ubuntu-latest
122+ if : github.repository_owner == env.REPO_OWNER
33123 env :
34124 BUILD_OUTPUT_PATH : _build/multiversion/
35125 steps :
42132 run : ls $BUILD_OUTPUT_PATH*
43133
44134 - name : rsync deployments
45- uses :
burnett01/[email protected] .0 135+ uses :
burnett01/[email protected] .1 46136 with :
47137 switches : -rvzh --delete-after --exclude=.git
48138 path : $BUILD_OUTPUT_PATH
0 commit comments