|
| 1 | +name: DDUF - Version and Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + newversion: |
| 7 | + type: choice |
| 8 | + description: "Semantic Version Bump Type" |
| 9 | + default: patch |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: "push-to-main" |
| 17 | + |
| 18 | +defaults: |
| 19 | + run: |
| 20 | + working-directory: packages/dduf |
| 21 | + |
| 22 | +jobs: |
| 23 | + version_and_release: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + # Needed to push the tag and the commit on the main branch, otherwise we get: |
| 29 | + # > Run git push --follow-tags |
| 30 | + # remote: error: GH006: Protected branch update failed for refs/heads/main. |
| 31 | + # remote: error: Changes must be made through a pull request. Required status check "lint" is expected. |
| 32 | + token: ${{ secrets.BOT_ACCESS_TOKEN }} |
| 33 | + - run: corepack enable |
| 34 | + - uses: actions/setup-node@v3 |
| 35 | + with: |
| 36 | + node-version: "20" |
| 37 | + cache: "pnpm" |
| 38 | + cache-dependency-path: | |
| 39 | + packages/dduf/pnpm-lock.yaml |
| 40 | + # setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED |
| 41 | + registry-url: "https://registry.npmjs.org" |
| 42 | + - run: pnpm install |
| 43 | + - run: git config --global user.name machineuser |
| 44 | + - run: git config --global user.email [email protected] |
| 45 | + - run: | |
| 46 | + PACKAGE_VERSION=$(node -p "require('./package.json').version") |
| 47 | + BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')") |
| 48 | + # Update package.json with the new version |
| 49 | + 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');" |
| 50 | + git commit . -m "🔖 @huggingface/dduf $BUMPED_VERSION" |
| 51 | + git tag "dduf-v$BUMPED_VERSION" |
| 52 | +
|
| 53 | + - name: "Check Deps are published before publishing this package" |
| 54 | + run: pnpm -w check-deps blob |
| 55 | + |
| 56 | + - run: pnpm publish --no-git-checks . |
| 57 | + env: |
| 58 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 59 | + - run: git pull --rebase && git push --follow-tags |
| 60 | + # hack - reuse actions/setup-node@v3 just to set a new registry |
| 61 | + - uses: actions/setup-node@v3 |
| 62 | + with: |
| 63 | + node-version: "20" |
| 64 | + registry-url: "https://npm.pkg.github.com" |
| 65 | + # Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558) |
| 66 | + # - run: pnpm publish --no-git-checks . |
| 67 | + # env: |
| 68 | + # NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + - name: "Update Doc" |
| 70 | + uses: peter-evans/repository-dispatch@v2 |
| 71 | + with: |
| 72 | + event-type: doc-build |
| 73 | + token: ${{ secrets.BOT_ACCESS_TOKEN }} |
0 commit comments