Tasks - Version and Release #227
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tasks - Version and Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| newversion: | |
| type: choice | |
| description: "Semantic Version Bump Type" | |
| default: patch | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| concurrency: | |
| group: "push-to-main" | |
| defaults: | |
| run: | |
| working-directory: packages/tasks | |
| permissions: | |
| contents: write | |
| id-token: write | |
| packages: write | |
| jobs: | |
| version_and_release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # Needed to push the tag and the commit on the main branch, otherwise we get: | |
| # > Run git push --follow-tags | |
| # remote: error: GH006: Protected branch update failed for refs/heads/main. | |
| # remote: error: Changes must be made through a pull request. Required status check "lint" is expected. | |
| token: ${{ secrets.BOT_ACCESS_TOKEN }} | |
| - run: npm install -g corepack@latest && corepack enable | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| cache: "pnpm" | |
| cache-dependency-path: | | |
| packages/tasks/pnpm-lock.yaml | |
| - run: pnpm install | |
| - run: git config --global user.name machineuser | |
| - run: git config --global user.email [email protected] | |
| - run: | | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')") | |
| # Update package.json with the new version | |
| node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');" | |
| git commit . -m "🔖 @huggingface/tasks $BUMPED_VERSION" | |
| git tag "tasks-v$BUMPED_VERSION" | |
| - run: (git pull --rebase && git push --follow-tags) || (git pull --rebase && git push --follow-tags) | |
| - run: pnpm publish --no-git-checks . | |
| # hack - reuse actions/setup-node@v4 just to set a new registry | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://npm.pkg.github.com" | |
| - run: pnpm publish --no-git-checks . | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: "Update Doc" | |
| uses: peter-evans/repository-dispatch@v2 | |
| with: | |
| event-type: doc-build | |
| token: ${{ secrets.BOT_ACCESS_TOKEN }} |