Skip to content

Commit b3e1141

Browse files
Grzegorz Olszewskimarcinaylien
Grzegorz Olszewski
authored andcommittedAug 6, 2021
chore: publish scripts update
1 parent 001c16c commit b3e1141

File tree

8 files changed

+81
-40
lines changed

8 files changed

+81
-40
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ no-post.api.yaml
33
# Dev
44
.idea
55
.vscode
6+
scripts/env
67

78
# Project specific
89
openapi-generator*
File renamed without changes.
File renamed without changes.

‎aylien/v1/news/config/javascript.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"projectName": "aylien-news-api",
33
"moduleName": "AylienNewsApi",
4-
"projectVersion": "4.6.0",
4+
"projectVersion": "4.6.1",
55
"licenseName": "Apache License, Version 2.0",
66
"modelPropertyNaming": "camelCase"
77
}

‎scripts/README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ sh ./install-openapi-generator.sh
1212

1313
## Generating the SDKs
1414

15-
The SDKs are generated from the API definition files found in the [`/aylien/v1/`](/aylien/v1) directory. There are also JSON configuration files in these directories for each language (see [`/aylien/v1/news/config`](/aylien/v1/news/config) for example). This process is automatic using the `generate-sdks.sh` script.
15+
> Note: Make sure you edit package version manually in `/aylien/v1/news/config/*.json` and in `/aylien/v1/news/*.yaml` into either `v4.x.x` or `v5.x.x`.
16+
17+
The SDKs are generated from the API definition files found in the [`/aylien/v1/`](/aylien/v1) directory. There are also JSON configuration files in these directories for each language (see [`/aylien/v1/news/config`](/aylien/v1/news/config) for example). This process is automatic using the `generate-sdks.sh <version>` script.
1618

1719
> Note: Make sure you have `gsed` installed.
1820
1921
```
20-
sh ./generate-sdks.sh
22+
sh ./generate-sdks.sh vX
2123
```
24+
> Note: Where `vX` is your version to generate. `ex. ./generate-sdks.sh v4`
25+
2226

2327
Please note that this script calls `install-openapi-generator.sh` if it can't find the `openapi-generator-cli.jar` file.
2428

@@ -112,7 +116,8 @@ Go directly retrieves the packages from Github, no publication necessary other t
112116
There is an automated script available for doing all of this, but you should only use it if you know what you are doing. Read the script before using it to understand how it works.
113117

114118
```
115-
sh ./publish.sh 'Release Note here'
119+
sh ./github-release.sh 'Release Notes here' 'Branch name here' 'x.x.x'
120+
sh ./publish.sh
116121
```
117122

118123
## Testing

‎scripts/generate-sdks.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
set -eu
44

5+
VERSION=$1
6+
7+
if [ -z "$VERSION" ]; then
8+
echo "Version to generate is required! ex. ./generate-sdks.sh v4 or ./generate-sdks.sh v5"
9+
exit -1
10+
fi
11+
512
if [ -n "${OPENAPI_CMD+1}" ]
613
then
714
echo "Using OpenAPI Generator command \`${OPENAPI_CMD}\`."
@@ -24,7 +31,7 @@ if [ "$OS" = 'Darwin' ]; then
2431
# for MacOS
2532
cmd=gsed
2633
fi
27-
cat ../aylien/v1/news/api-v5.yaml | tr '\n' '\r' | $cmd -e 's/\s\s\+tags:\r\s*- \w*//g' | tr '\r' '\n' > temp.api.yaml
34+
cat ../aylien/v1/news/api-${VERSION}.yaml | tr '\n' '\r' | $cmd -e 's/\s\s\+tags:\r\s*- \w*//g' | tr '\r' '\n' > temp.api.yaml
2835

2936
python remove-post-body.py temp.api.yaml no-post.api.yaml
3037

‎scripts/github-release.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
cd ../sdks/news-api
2+
3+
release_note=${1:-"minor update"}
4+
branch_name=${2:-"release"}
5+
release_version=$3
6+
7+
function git_push() {
8+
rm -rf .git
9+
git init
10+
git add .
11+
git commit -m "$release_note"
12+
git remote add origin git@github.com:aylien/aylien_newsapi_$lang
13+
14+
git pull origin master -s recursive -Xtheirs
15+
git checkout -b $branch_name
16+
git push
17+
18+
git tag -a v$release_version -m "${release_note}"
19+
git push --tags
20+
}
21+
22+
function git_push_javascript() {
23+
rm -rf .git
24+
git init
25+
git add .
26+
git commit -m "$release_note"
27+
git remote add origin git@github.com:aylien/aylien_newsapi_nodejs
28+
29+
git pull origin master -s recursive -Xtheirs
30+
git checkout -b $branch_name
31+
git rm -r node_modules
32+
git rm -r dist
33+
git commit -a --amend --no-edit
34+
git push
35+
36+
git tag -a v$release_version -m "${release_note}"
37+
git push --tags
38+
}
39+
40+
cd javascript
41+
git_push_javascript
42+
cd ..
43+
44+
echo "python: publishing to pypi"
45+
echo "- using PYPI_USERNAME and PYPI_PASSWORD env variables"
46+
cd python
47+
lang=python
48+
git_push
49+
cd ..
50+
51+
cd ruby
52+
lang=ruby
53+
git_push
54+
cd ..
55+
56+
echo "go: there is no publication necessary, users pull directly from github."
57+
cd go
58+
lang=go
59+
git_push
60+
cd ..

‎scripts/publish.sh

+3-35
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,20 @@
11
cd ../sdks/news-api
22

3-
release_note=${1:-"minor update"}
4-
5-
function git_push() {
6-
rm -rf .git
7-
git init
8-
git add .
9-
git commit -m "$release_note"
10-
git remote add origin git@github.com:aylien/aylien_newsapi_$lang
11-
12-
git pull origin master -s recursive -X theirs
13-
git cherry-pick --skip
14-
git rebase --continue
15-
git push origin master
16-
}
17-
183
echo "javascript: publishing to npm"
194
if [ ! -f "$HOME/.npmrc" ]; then
205
echo "- $HOME/.npmrc not found, using NPM_AUTH_TOKEN from env to create it."
216
echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >$HOME/.npmrc
227
fi
238

249
cd javascript
25-
lang=nodejs
26-
git_push
27-
2810
npm install
2911
npm run build
3012
npm publish
3113
cd ..
3214

33-
echo "python: publishing to pypi"
34-
echo "- using PYPI_USERNAME and PYPI_PASSWORD env variables"
3515
cd python
36-
lang=python
37-
git_push
38-
39-
pip install twine
40-
python setup.py sdist bdist_wheel
16+
pip3 install twine
17+
python3 setup.py sdist bdist_wheel
4118
twine check dist/*
4219
twine upload --non-interactive -u $PYPI_USERNAME -p $PYPI_PASSWORD dist/*
4320
cd ..
@@ -48,16 +25,7 @@ if [ ! -f "$HOME/.gem/credentials" ]; then
4825
mkdir -p $HOME/.gem
4926
echo ":rubygems_api_key: $GEM_API_KEY" >$HOME/.gem/credentials
5027
fi
51-
cd ruby
52-
lang=ruby
53-
git_push
54-
28+
cd ruby
5529
gem build aylien_news_api.gemspec
5630
gem push aylien_news_api-*.gem
5731
cd ..
58-
59-
echo "go: there is no publication necessary, users pull directly from github."
60-
cd go
61-
lang=go
62-
git_push
63-
cd ..

0 commit comments

Comments
 (0)
Please sign in to comment.