Skip to content

🔖 Auto release gh action #35

🔖 Auto release gh action

🔖 Auto release gh action #35

name: 🔖 Auto release gh action
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Commit Count
id: get_commit
run: git rev-list `git rev-list --tags --no-walk --max-count=1`..HEAD --count | xargs -I {} echo COMMIT_COUNT={} >> $GITHUB_OUTPUT
- name: Set up Go
if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }}
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Bump version
if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }}
run: |
curl -LO https://raw.githubusercontent.com/projectdiscovery/utils/main/scripts/versionbump/versionbump.go
go run versionbump.go -file cmd/mapcidr/main.go -var version -part patch
- name: Create local changes
if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }}
run: |
git add cmd/mapcidr/main.go
- name: Commit files
if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "Bump version"
- name: Push changes
if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Create release and tag
if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }}
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}