name: "Draft New Release"
run-name: "Draft: v${{ github.event.inputs.version }}"
on:
workflow_dispatch:
inputs:
version:
description: "eg. 0.1.0"
required: true
jobs:
apply-version:
name: "Apply Version"
runs-on: ubuntu-latest
permissions:
contents: write
env:
PUBLISH_VERSION: ${{ github.event.inputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: "main"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo install cargo-bump
- run: cargo bump ${{ env.PUBLISH_VERSION }}
- run: cargo build
- name: "Commit and Push"
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git checkout ${{ env.BRANCH }}
git add .
git commit -m "v$PUBLISH_VERSION"
git push origin HEAD:refs/heads/${{ env.BRANCH }}
- name: "Create Release"
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "v${{ env.PUBLISH_VERSION }}",
"target_commitish": "${{ env.BRANCH }}",
"name": "v${{ env.PUBLISH_VERSION }}",
"body": "",
"draft": true,
"prerelease": false
}' \
https://api.github.com/repos/${{ github.repository }}/releases