diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bf3d77f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version_bump: + description: 'Version bump type' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + +env: + CARGO_TERM_COLOR: always + +jobs: + release: + name: Create Release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable + + - name: Install cargo-edit + run: cargo install cargo-edit + + - name: Bump version + run: | + cargo set-version --bump ${{ inputs.version_bump }} + NEW_VERSION=$(grep -m1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/') + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + echo "Bumped version to: $NEW_VERSION" + + - name: Build project + run: cargo build --all-targets + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Commit and push changes + run: | + git add Cargo.toml Cargo.lock + git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" + git tag -a "v${{ env.NEW_VERSION }}" -m "Release v${{ env.NEW_VERSION }}" + git push origin main + git push origin "v${{ env.NEW_VERSION }}" + + - name: Create GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "v${{ env.NEW_VERSION }}" \ + --title "v${{ env.NEW_VERSION }}" \ + --generate-notes \ + --draft