diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index cb8f29b0..763f70ad 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -17,7 +17,7 @@ jobs: - name: ⬇️ Checkout repo uses: actions/checkout@v4 with: - fetch-depth: 2 + fetch-depth: 0 # Ensure full history is fetched for tagging - name: Set up conda uses: conda-incubator/setup-miniconda@v2 @@ -25,11 +25,6 @@ jobs: activate-environment: default environment-file: api/environment.yml - - name: ⬇️ Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: ⎔ Setup Node uses: actions/setup-node@v3 with: @@ -49,42 +44,38 @@ jobs: - name: Install dependencies run: npm install - - name: 📦 Electron Builder - run: npm run electron:package:win - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Bump version + id: bump_version + run: | + # Bump version using npm + CURRENT_VERSION=$(jq -r '.version' package.json) + NEW_VERSION=$(npm version patch -m "chore(release): $CURRENT_VERSION -> %s [skip ci]") + NEW_VERSION=$(echo $NEW_VERSION | tr -d 'v') # Remove the 'v' prefix + echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV - - name: Print directory tree - run: tree - - - name: Get latest release number - id: get_latest_release - uses: actions/github-script@v4 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const response = await github.repos.listReleases({ - owner: context.repo.owner, - repo: context.repo.repo, - per_page: 10 - }); - - const latestPreRelease = response.data[0]; - const preReleaseTag = latestPreRelease.name; - const versionParts = preReleaseTag.replace(/^v/, '').split('.'); - const newVersion = `${parseInt(versionParts[0])}.${parseInt(versionParts[1])}.${parseInt(versionParts[2]) + 1}`; - console.log(`::set-output name=new_version::${newVersion}`); + - name: Commit new version + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -am "chore: bump version to ${{ env.NEW_VERSION }}" + git tag v${{ env.NEW_VERSION }} + git push origin develop --tags - name: Rename file - run: ren "dist\LinguifAI Setup 0.1.0.exe" "LinguifAI Setup ${{ steps.get_latest_release.outputs.new_version }}.exe" + run: | + OLD_NAME=$(ls dist | grep 'LinguifAI Setup') + NEW_NAME="LinguifAI Setup ${{ env.NEW_VERSION }}.exe" + mv "dist/$OLD_NAME" "dist/$NEW_NAME" - name: Create Release id: create_release uses: softprops/action-gh-release@v1 with: files: | - ./dist/LinguifAI\ Setup\ ${{ steps.get_latest_release.outputs.new_version }}.exe - tag_name: v${{ steps.get_latest_release.outputs.new_version }} - name: v${{ steps.get_latest_release.outputs.new_version }} + ./dist/LinguifAI\ Setup\ ${{ env.NEW_VERSION }}.exe + tag_name: v${{ env.NEW_VERSION }} + name: v${{ env.NEW_VERSION }} prerelease: true body: ${{ github.event.head_commit.message }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}