From 11d9f89d8c3906d0c837a067c3a0329f0de212f4 Mon Sep 17 00:00:00 2001 From: gary-Shen Date: Mon, 5 Feb 2024 18:34:49 +0800 Subject: [PATCH] fix: update ci --- .github/workflows/release.yml | 56 +++++++++++++++++++---------------- .releaserc.json | 4 +-- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a9047a..d680ee3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,30 @@ on: - 'main' - 'alpha' jobs: + prepare: + runs-on: unbuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: actions/setup-node@v4 + with: + node-version: 20.8.1 + + - name: Semantic Release dry-run + id: dry-run + uses: cycjimmy/semantic-release-action@v4 + with: + dry_run: true + extra_plugins: | + @semantic-release/commit-analyzer + @semantic-release/exec + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + release: + needs: prepare strategy: fail-fast: false matrix: @@ -36,30 +59,15 @@ jobs: # ====================== release ====================== - - - uses: actions/setup-node@v4 - with: - node-version: 20.8.1 - - - name: Semantic Release dry-run - uses: cycjimmy/semantic-release-action@v4 - with: - dry_run: true - extra_plugins: | - @semantic-release/commit-analyzer - @semantic-release/exec - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Set test pip url if: ${{ github.ref_name == 'alpha' }} run: | - echo "PYPI_URL=https://test.pypi.org/project/labelu/${{ env.NEXT_VERSION }}" >> $GITHUB_ENV + echo "PYPI_URL=https://test.pypi.org/project/labelu/${{ needs.prepare.outputs.NEXT_VERSION }}" >> $GITHUB_ENV - name: Set release pip url if: ${{ github.ref_name == 'main' }} run: | - echo "PYPI_URL=https://pypi.org/project/labelu/${{ env.NEXT_VERSION }}" >> $GITHUB_ENV + echo "PYPI_URL=https://pypi.org/project/labelu/${{ needs.prepare.outputs.NEXT_VERSION }}" >> $GITHUB_ENV - name: Show pypi url run: | @@ -68,6 +76,8 @@ jobs: - name: Inject backend info into frontend uses: satackey/action-js-inline@v0.0.2 id: InjectBackend + env: + NEXT_VERSION: ${{ needs.prepare.outputs.NEXT_VERSION }} with: required-packages: '@iarna/toml' script: | @@ -112,7 +122,6 @@ jobs: poetry-version: ${{ matrix.poetry-version }} - name: Install dependencies - if: ${{ env.NEXT_VERSION != '' }} run: poetry install --without dev - name: Run tests @@ -126,19 +135,17 @@ jobs: verbose: true - name: Manage version - if: ${{ env.NEXT_VERSION != '' }} run: | sed -i "s/^version[ ]*=.*/version = '${NEXT_VERSION}'/" pyproject.toml - name: Commit version change - if: ${{ env.NEXT_VERSION != '' }} uses: stefanzweifel/git-auto-commit-action@v4 with: - commit_message: 'chore: Upgrade to v${{ env.NEXT_VERSION }} [skip ci]' + commit_message: 'chore: Upgrade to v${{ needs.prepare.outputs.NEXT_VERSION }} [skip ci]' file_pattern: pyproject.toml - name: Publish to TestPyPi - if: ${{ github.ref_name == 'alpha' && env.NEXT_VERSION != ''}} + if: ${{ github.ref_name == 'alpha'}} env: TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }} run: | @@ -146,7 +153,7 @@ jobs: poetry publish --build --skip-existing -r testpypi - name: Publish to PyPi - if: ${{ github.ref_name == 'main' && env.NEXT_VERSION != ''}} + if: ${{ github.ref_name == 'main'}} env: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} run: | @@ -167,11 +174,10 @@ jobs: # ====================== post release ====================== - name: Send webhook message - if: ${{ env.RELEASE_NOTES != '' }} uses: joelwmale/webhook-action@master env: CHANGELOG: ${{ github.event.inputs.changelog != '' && format('## Frontend changelog \n{0}\n\n\n', github.event.inputs.changelog) || '' }} with: url: ${{ secrets.WEBHOOK_URL }} headers: '{"Content-Type": "application/json"}' - body: '{"msgtype":"markdown","markdown":{"content":"${{ env.RELEASE_NOTES }}${{ env.CHANGELOG }}Check it out now \ud83d\udc49\ud83c\udffb [v${{ env.NEXT_VERSION }}](${{ env.PYPI_URL }})"}}' + body: '{"msgtype":"markdown","markdown":{"content":"${{ needs.prepare.outputs.RELEASE_NOTES }}${{ env.CHANGELOG }}Check it out now \ud83d\udc49\ud83c\udffb [v${{ needs.prepare.outputs.NEXT_VERSION }}](${{ env.PYPI_URL }})"}}' diff --git a/.releaserc.json b/.releaserc.json index b0e966a..4937c37 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -21,8 +21,8 @@ [ "@semantic-release/exec", { - "verifyReleaseCmd": "echo \"NEXT_VERSION=${nextRelease.version}\" >> $GITHUB_ENV", - "successCmd": "echo \"RELEASE_NOTES<> $GITHUB_ENV" + "verifyReleaseCmd": "echo \"NEXT_VERSION=${nextRelease.version}\" >> $GITHUB_OUTPUT", + "successCmd": "echo \"RELEASE_NOTES<> $GITHUB_OUTPUT" } ] ]