From dfec1a16f9b50ae95e7f6393de8fc41c7397e295 Mon Sep 17 00:00:00 2001 From: Zakaria Mansouri Date: Sun, 17 Nov 2024 18:26:10 +0100 Subject: [PATCH] apply version via github action --- .github/workflows/draft-new-release.yml | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/draft-new-release.yml diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml new file mode 100644 index 0000000..dbacd8e --- /dev/null +++ b/.github/workflows/draft-new-release.yml @@ -0,0 +1,49 @@ +name: "Draft New Release" + +on: + workflow_dispatch: + inputs: + version: + description: "eg. 0.1.0" + required: true + +jobs: + apply-version: + name: cargo bump + 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