diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a0e3fc3..e3319dbd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,13 +6,13 @@ on: - 'release' - 'alpha' jobs: - test: + release: strategy: fail-fast: false matrix: python-version: [3.7] poetry-version: ['1.2.2'] - node-version: [20.8.1] + node-version: [20] os: [ubuntu-20.04] runs-on: ${{ matrix.os }} steps: @@ -34,78 +34,79 @@ jobs: 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/action-js-inline@v0.0.2 - 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 + # - name: Inject backend info into frontend + # uses: satackey/action-js-inline@v0.0.2 + # 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 ====================== diff --git a/.github/workflows/trigger_from_labelu_kit.yml b/.github/workflows/trigger_from_labelu_kit.yml index 5ffb5bb1..23f558bf 100644 --- a/.github/workflows/trigger_from_labelu_kit.yml +++ b/.github/workflows/trigger_from_labelu_kit.yml @@ -41,6 +41,7 @@ on: type: string jobs: update-frontend: + if: github.event_name == 'workflow_dispatch' strategy: fail-fast: false matrix: @@ -62,7 +63,7 @@ jobs: - name: Update .VERSION file run: | - sh ./scripts/resolve_frontend.sh release $FRONTEND_VERSION $FRONTEND_ASSET_URL + sh ./scripts/resolve_frontend.sh ${{ inputs.release_type }} $FRONTEND_VERSION $FRONTEND_ASSET_URL env: FRONTEND_VERSION: ${{ inputs.version }}