|
| 1 | +name: Publish to NPM and Release on Github |
| 2 | +on: |
| 3 | + workflow_dispatch: # Allows manual triggering of the workflow |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: write |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Bump Version, Build, and Publish to NPM |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Set up Node.js |
| 18 | + uses: actions/setup-node@v3 |
| 19 | + with: |
| 20 | + node-version: 21 |
| 21 | + cache: "npm" |
| 22 | + |
| 23 | + - name: Install dependencies |
| 24 | + run: npm install |
| 25 | + |
| 26 | + - name: Bump Version |
| 27 | + id: bump-version |
| 28 | + run: | |
| 29 | + NEW_VERSION=$(npm version patch --no-git-tag-version) |
| 30 | + echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV |
| 31 | + echo "Updated version to ${NEW_VERSION}" |
| 32 | +
|
| 33 | + - name: Commit and Push New Version |
| 34 | + env: |
| 35 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + run: | |
| 37 | + git config user.name "GitHub Actions" |
| 38 | + git config user.email "[email protected]" |
| 39 | + git add package.json package-lock.json |
| 40 | + git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" |
| 41 | + git push origin main |
| 42 | +
|
| 43 | + - name: Build package |
| 44 | + run: npm run build |
| 45 | + |
| 46 | + - name: Publish to npm |
| 47 | + env: |
| 48 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 49 | + run: npm publish |
| 50 | + |
| 51 | + - name: Create GitHub Release |
| 52 | + uses: softprops/action-gh-release@v2 |
| 53 | + with: |
| 54 | + tag_name: "${{ env.NEW_VERSION }}" # Use the version passed from the build job |
| 55 | + name: "Release ${{ env.NEW_VERSION }}" # Name the release with the version. |
| 56 | + generate_release_notes: true # Generate release notes |
| 57 | + draft: false # The release will not be a draft. |
| 58 | + prerelease: false # The release will not be a pre-release. |
| 59 | + body: | |
| 60 | + New release of **expo-check-installed-apps** is available. |
| 61 | + - Version: ${{ env.NEW_VERSION }} |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments