| 
 | 1 | +# Create and push the commit and tag created from npm version <version>  | 
 | 2 | +#   | 
 | 3 | +# From the Actions page on GitHub, users (with write permissions) can select  | 
 | 4 | +# the desired release <version> and this action will handle running npm version  | 
 | 5 | +# and pushing the tag to the repository.  | 
 | 6 | +#  | 
 | 7 | +# Due to the VERSION_TOKEN, the tag push will trigger release.yml, which handles  | 
 | 8 | +# releasing to npm and GitHub releases.  | 
 | 9 | +#  | 
 | 10 | +# With pre* versions (prerelease, prepatch, etc.), the tag will be created with  | 
 | 11 | +# --preid beta. Currently, they are released normally, to --tag latest on npm.  | 
 | 12 | + | 
 | 13 | +name: Push new version  | 
 | 14 | + | 
 | 15 | +on:  | 
 | 16 | +  workflow_dispatch:  | 
 | 17 | +    inputs:  | 
 | 18 | +      version:  | 
 | 19 | +        description: 'npm version semver level'  | 
 | 20 | +        required: true  | 
 | 21 | +        default: 'patch'  | 
 | 22 | +        type: choice  | 
 | 23 | +        options:  | 
 | 24 | +        - patch  | 
 | 25 | +        - minor  | 
 | 26 | +        - major  | 
 | 27 | +        - prerelease  | 
 | 28 | +        - prepatch  | 
 | 29 | +        - preminor  | 
 | 30 | +        - premajor  | 
 | 31 | + | 
 | 32 | +jobs:  | 
 | 33 | +  version:  | 
 | 34 | +    name: Push ${{ inputs.version }} tag  | 
 | 35 | +    runs-on: ubuntu-latest  | 
 | 36 | + | 
 | 37 | +    steps:  | 
 | 38 | +    - name: Checkout branch  | 
 | 39 | +      uses: actions/checkout@v4  | 
 | 40 | +      with:  | 
 | 41 | +        # see https://github.com/orgs/community/discussions/25617#discussioncomment-3248494  | 
 | 42 | +        token: ${{ secrets.VERSION_TOKEN }}  | 
 | 43 | +        # requires contents: write permission for this repo  | 
 | 44 | +        # used by `git push` at the end  | 
 | 45 | +    - uses: actions/setup-node@v4  | 
 | 46 | +      with:  | 
 | 47 | +        node-version: 22.x  | 
 | 48 | +    - name: Configure git user  | 
 | 49 | +      # this step is necessary for `npm version` to succeed  | 
 | 50 | +      run: |  | 
 | 51 | +        git config --global user.name "${{ github.actor }}"  | 
 | 52 | +        git config --global user.email "${{ github.actor }}@users.noreply.github.com"  | 
 | 53 | +    - name: npm version ${{ inputs.version }}  | 
 | 54 | +      run: echo "version=$(npm version ${{ inputs.version }}${{ startsWith(inputs.version, 'pre') && '--preid beta' || '' }})" >> "$GITHUB_ENV"  | 
 | 55 | +    - name: git push  | 
 | 56 | +      run: git push && git push origin ${{ env.version }}  | 
0 commit comments