Skip to content

Commit

Permalink
fix: update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-Shen committed Feb 5, 2024
1 parent 566558c commit 11d9f89
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
56 changes: 31 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand All @@ -68,6 +76,8 @@ jobs:
- name: Inject backend info into frontend
uses: satackey/[email protected]
id: InjectBackend
env:
NEXT_VERSION: ${{ needs.prepare.outputs.NEXT_VERSION }}
with:
required-packages: '@iarna/toml'
script: |
Expand Down Expand Up @@ -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
Expand All @@ -126,27 +135,25 @@ 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: |
poetry config pypi-token.testpypi $TEST_PYPI_TOKEN
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: |
Expand All @@ -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 }})"}}'
4 changes: 2 additions & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
[
"@semantic-release/exec",
{
"verifyReleaseCmd": "echo \"NEXT_VERSION=${nextRelease.version}\" >> $GITHUB_ENV",
"successCmd": "echo \"RELEASE_NOTES<<EOF\n${nextRelease.notes}\nEOF\" >> $GITHUB_ENV"
"verifyReleaseCmd": "echo \"NEXT_VERSION=${nextRelease.version}\" >> $GITHUB_OUTPUT",
"successCmd": "echo \"RELEASE_NOTES<<EOF\n${nextRelease.notes}\nEOF\" >> $GITHUB_OUTPUT"
}
]
]
Expand Down

0 comments on commit 11d9f89

Please sign in to comment.