mirror of
https://gitea.com/gitea/docs.git
synced 2026-03-27 05:58:30 +07:00
Fix update swagger json (#150)
I can not understand the old logic: - download the web page (not the raw data) from GitHub - replace `AppVer` - remove the file??? It does nothing. The correct logic: - download the raw file from GitHub - replace `AppVer` and `AppSubUrl` - move the file to the correct place As the script is not correct for a long time, added the support for all version since 1.19. Fix #142 Reviewed-on: https://gitea.com/gitea/docs/pulls/150 Reviewed-by: Lunny Xiao <lunny@noreply.gitea.com> Co-authored-by: yp05327 <576951401@qq.com> Co-committed-by: yp05327 <576951401@qq.com>
This commit is contained in:
@@ -11,13 +11,21 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
wget https://github.com/go-gitea/gitea/blob/main/templates/swagger/v1_json.tmpl
|
||||
sed -i "$@" 's/"version": "{{AppVer | JSEscape}}"/"version": "dev"/' static/swagger-latest.json
|
||||
rm v1_json.tmpl
|
||||
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/heads/main/templates/swagger/v1_json.tmpl
|
||||
sed -i "$@" 's\"version": "{{AppVer | JSEscape}}"\"version": "dev"\' v1_json.tmpl
|
||||
sed -i "$@" 's\"basePath": "{{AppSubUrl | JSEscape}}/api/v1"\"basePath": "https://gitea.com/api/v1"\' v1_json.tmpl
|
||||
mv v1_json.tmpl static/swagger-latest.json
|
||||
|
||||
wget https://github.com/go-gitea/gitea/blob/v1.23.0/templates/swagger/v1_json.tmpl
|
||||
sed -i "$@" 's/"version": "{{AppVer | JSEscape}}"/"version": "1.23.1"/' static/swagger-23.json
|
||||
rm v1_json.tmpl
|
||||
for ver in '1.23.1' '1.22.6' '1.21.11' '1.20.6' '1.19.4'; do
|
||||
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v${ver}/templates/swagger/v1_json.tmpl
|
||||
sed -i "$@" "s|\"version\": \"{{AppVer \| JSEscape}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
|
||||
sed -i "$@" 's\"basePath": "{{AppSubUrl | JSEscape}}/api/v1"\"basePath": "https://gitea.com/api/v1"\' v1_json.tmpl
|
||||
# for version < 1.21.11
|
||||
sed -i "$@" "s|\"version\": \"{{AppVer \| JSEscape \| Safe}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
|
||||
sed -i "$@" 's\"basePath": "{{AppSubUrl | JSEscape | Safe}}/api/v1"\"basePath": "https://gitea.com/api/v1"\' v1_json.tmpl
|
||||
minor=$(echo "$ver" | cut -d '.' -f 2)
|
||||
mv v1_json.tmpl static/swagger-$minor.json
|
||||
done
|
||||
|
||||
if ! [[ $(git diff --shortstat) ]]; then exit 0; fi
|
||||
git config --global user.name "Gitea Bot"
|
||||
|
||||
Reference in New Issue
Block a user