Skip to content

Merge pull request #78 from opendatalab/dev #2

Merge pull request #78 from opendatalab/dev

Merge pull request #78 from opendatalab/dev #2

Workflow file for this run

name: 'release'
on:
push:
branches:
- 'release'
- 'alpha'
jobs:
release:
strategy:
fail-fast: false
matrix:
python-version: [3.7]
poetry-version: ['1.2.2']
node-version: [20]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download frontend
run: |
sh ./scripts/resolve_frontend.sh true
# ====================== release ======================
- name: Semantic release in dry-run mode
run: |
npm i -g semantic-release @semantic-release/github @semantic-release/changelog @semantic-release/git
echo "NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'the next release version is' | sed -E 's/.* ([0-9a-z.-]+)$/\1/')" >> $GITHUB_ENV
echo "$NEXT_VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Inject backend info into frontend
# uses: satackey/[email protected]
# id: InjectBackend
# with:
# required-packages: '@iarna/toml'
# script: |
# const fs = require('fs');
# const path = require('path');
# const toml = require('@iarna/toml');
# const rootPath = path.join(process.cwd(), '');
# console.log('rootPath', rootPath);
# try {
# const projectInfo = toml.parse(
# fs.readFileSync(path.join(rootPath, 'pyproject.toml'), 'utf8')
# );
# const backendInfo = {
# version: process.env.NEXT_VERSION,
# name: projectInfo.tool.poetry.name || 'LabelU',
# build_time: new Date().toISOString(),
# commit: process.env.GITHUB_SHA,
# };
# const code = `
# (function () {
# window.__backend = ${JSON.stringify(backendInfo, null, 2)};
# })();
# `;
# fs.writeFileSync(
# path.join(rootPath, 'labelu/internal/statics/backend_version.js'),
# code,
# 'utf-8'
# );
# console.log('Update backend_version.js success!');
# } catch (e) {
# console.error(e);
# process.exit(1);
# }
# - uses: abatilo/actions-poetry@v2
# with:
# poetry-version: ${{ matrix.poetry-version }}
# - name: Install dependencies
# run: poetry install --without dev
# - name: Run tests
# run: poetry run pytest --cov=./ --cov-report=xml
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
# files: ./coverage.xml
# verbose: true
# - name: Manage version
# run: |
# sed -i "s/^version[ ]*=.*/version = '${NEXT_VERSION}'/" pyproject.toml
# - name: Publish
# env:
# PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
# run: |
# poetry config pypi-token.pypi $PYPI_TOKEN
# poetry publish --build --skip-existing
# ====================== post release ======================
- name: Webhook message
uses: joelwmale/webhook-action@master
with:
url: ${{ secrets.WEBHOOK_URL }}
headers: '{"Content-Type": "application/json"}'
body: '{"msgtype":"markdown","markdown":{"content":"# LabelU@${{ env.NEXT_VERSION }} is Released 🎉\n \nCheck it out now \ud83d\udc49\ud83c\udffb [v${{ env.NEXT_VERSION }}](https://pypi.org/project/labelu/#files) \n \n ## Changelog \n \n${{ github.event.head_commit.message }}"}}'