chore: trigger workflow #4
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate a token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.REVENG_APP_ID }} | |
| private-key: ${{ secrets.REVENG_APP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: | | |
| plugin-binary-ninja | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - name: Calculate next version | |
| id: version | |
| run: | | |
| set -euo pipefail | |
| LATEST_TAG=$(git tag -l "v*" --sort=-v:refname | head -1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| CURRENT_VERSION="0.0.0" | |
| RANGE="HEAD" | |
| else | |
| CURRENT_VERSION="${LATEST_TAG#v}" | |
| RANGE="${LATEST_TAG}..HEAD" | |
| fi | |
| COMMITS=$(git log --pretty=format:"%s" "$RANGE") | |
| if [ -z "$COMMITS" ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| MAJOR=0; MINOR=0; PATCH=0 | |
| CHANGELOG="" | |
| while IFS= read -r msg; do | |
| [ -z "$msg" ] && continue | |
| CHANGELOG="${CHANGELOG}- ${msg}\n" | |
| if echo "$msg" | grep -qE '!:|BREAKING CHANGE'; then | |
| MAJOR=1 | |
| elif echo "$msg" | grep -qE '^feat(\(.*\))?:'; then | |
| MINOR=1 | |
| elif echo "$msg" | grep -qE '^fix(\(.*\))?:'; then | |
| PATCH=1 | |
| fi | |
| done <<< "$COMMITS" | |
| if [ $MAJOR -eq 0 ] && [ $MINOR -eq 0 ] && [ $PATCH -eq 0 ]; then | |
| PATCH=1 | |
| fi | |
| IFS='.' read -r CUR_MAJOR CUR_MINOR CUR_PATCH <<< "$CURRENT_VERSION" | |
| if [ $MAJOR -eq 1 ]; then | |
| NEXT_VERSION="$((CUR_MAJOR + 1)).0.0" | |
| elif [ $MINOR -eq 1 ]; then | |
| NEXT_VERSION="${CUR_MAJOR}.$((CUR_MINOR + 1)).0" | |
| else | |
| NEXT_VERSION="${CUR_MAJOR}.${CUR_MINOR}.$((CUR_PATCH + 1))" | |
| fi | |
| echo "version=${NEXT_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag=v${NEXT_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo -e "$CHANGELOG" > /tmp/changelog.md | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| - name: Create tag and release | |
| if: steps.version.outputs.skip != 'true' | |
| env: | |
| GH_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag "${{ steps.version.outputs.tag }}" | |
| git push origin "${{ steps.version.outputs.tag }}" | |
| gh release create "${{ steps.version.outputs.tag }}" \ | |
| --title "${{ steps.version.outputs.tag }}" \ | |
| --notes-file /tmp/changelog.md |