# main only name: Integrate on: push: branches: [main] env: FORCE_COLOR: 1 jobs: tagIfNewVersion: name: Tag if new version runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 with: # Ensure to have complete history of commits pushed with given push operation # It's loose and imperfect assumption that no more than 30 commits will be pushed at once fetch-depth: 30 # Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow # Hence we're passing 'serverless-ci' user authentication token token: ${{ secrets.USER_GITHUB_TOKEN }} - name: Tag if new version if: github.event.before != '0000000000000000000000000000000000000000' # Skip on first commit run: | NEW_VERSION=`git diff -U0 ${{ github.event.before }} package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : if [ -n "$NEW_VERSION" ]; then git tag v$NEW_VERSION git push --tags fi