update version #462
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
Prepare: | |
name: Setup environment | |
if: ${{ github.event.label.name != 'no-build' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repsitory | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
fetch-depth: 1 | |
submodules: recursive | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.7.17 | |
- name: Cache Python packages | |
id: cache-python | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ env.pythonLocation }}$-${{ hashFiles('requirements.txt') }} | |
- name: Install MegEngine and Python dependencies | |
if: steps.cache-python.outputs.cache-hit != 'true' | |
run: | | |
python3 -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install megengine -f https://megengine.org.cn/whl/mge.html | |
Generate: | |
name: Build HTML files | |
needs: Prepare | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
language: ["zh_CN", "en"] | |
steps: | |
- name: Checkout repsitory | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
fetch-depth: 1 | |
submodules: recursive | |
- name: LFS - Create hash files | |
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
- name: LFS - Restore cache | |
uses: actions/cache@v3 | |
id: lfs-cache | |
with: | |
path: .git/lfs | |
key: ${{ hashFiles('.lfs-assets-id') }} | |
- name: LFS - pull missed files | |
run: git lfs pull | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.7.17 | |
- name: Get cached Python packages | |
id: cache-python | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ env.pythonLocation }}$-${{ hashFiles('requirements.txt') }} | |
- name: Install pandoc and other dependencies | |
run: sudo apt install -y pandoc graphviz | |
- name: Generate HTML files | |
run: | | |
make LANGUAGE=${{ matrix.language }} html | |
mv build/html ${{ matrix.language }} | |
tar czf ${{ matrix.language }}.tgz ${{ matrix.language }} | |
- name: Upload aritifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: HTML | |
path: ${{ matrix.language }}.tgz | |
Deploy: | |
name: Deploy on OSS | |
needs: Generate | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repsitory | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
fetch-depth: 1 | |
lfs: true | |
- name: Download aritifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: HTML | |
- name: Deploy on OSS | |
run: | | |
tar xzf zh_CN.tgz && mv zh_CN zh | |
tar xzf en.tgz | |
tar czf static.tgz zh en | |
export GIT_HASH=$(git rev-parse --short HEAD) && echo $GIT_HASH | |
wget http://gosspublic.alicdn.com/ossutil/1.7.7/ossutil64 | |
chmod 755 ossutil64 | |
./ossutil64 config -e ${{ secrets.OSS_PROD_ENDPOINT }} -i ${{ secrets.OSS_PROD_ACCESS_KEY_ID }} -k ${{ secrets.OSS_PROD_ACCESS_KEY_SECRET }} | |
./ossutil64 mkdir oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/commit-$GIT_HASH | |
./ossutil64 cp static.tgz oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/commit-$GIT_HASH/static.tgz | |
./ossutil64 cp -f oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/mapping.json . | |
export MGE_DOC_MODE="MINI" | |
version=`python3 -c "from source.conf import version; print(version)"` | |
python3 scripts/oss/update.py -v ${version} -c ${GIT_HASH} | |
python3 scripts/oss/update.py -v "stable" -c ${GIT_HASH} | |
python3 scripts/oss/gen_version.py | |
./ossutil64 cp -f version.json oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/version.json | |
./ossutil64 cp -f mapping.json oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/mapping.json | |