Skip to content

Draft:

Draft: #1

name: "Draft New Release"
run-name: "Draft: ${{ github.event.inputs.project }}${{ github.event.inputs.version }}"
on:
pull_request:
# workflow_dispatch:
# inputs:
# project:
# type: choice
# options:
# - "c"
# - "csharp"
# - "d"
# - "java"
# - "javascript"
# - "php"
# - "python"
# - "rust"
# required: true
# version:
# description: "eg. 0.1.0"
# required: true
jobs:
apply-version-rust:
# name: "Apply Version for: ${{ github.event.inputs.project }}"
name: "Apply Version for: rust"
runs-on: ubuntu-latest
# if: ${{ github.event.inputs.project == 'rust' }}
if: ${{ 'rust' == 'rust' }}
env:
# CWD: "./${{ github.event.inputs.project }}"
# PROJECT: ${{ github.event.inputs.project }}
# PUBLISH_VERSION: ${{ github.event.inputs.version }}
# BRANCH: "main"
CWD: "./rust"
PROJECT: rust
PUBLISH_VERSION: "0.1.0"
BRANCH: "chore/draf-release-via-github-action"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo install cargo-bump
working-directory: ${{ env.CWD }}
- run: cargo bump ${{ env.PUBLISH_VERSION }}
working-directory: ${{ env.CWD }}
- run: cargo build
working-directory: ${{ env.CWD }}
- 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 "$PROJECT$PUBLISH_VERSION"
git push origin HEAD:refs/heads/${{ env.BRANCH }}
draft-github-release:
name: "Draft GitHub Release"
runs-on: ubuntu-latest
needs: [apply-version-rust]
permissions:
contents: write
env:
# PROJECT: ${{ github.event.inputs.project }}
# PUBLISH_VERSION: ${{ github.event.inputs.version }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# BRANCH: "main"
PROJECT: rust
PUBLISH_VERSION: "0.1.0"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: "chore/draf-release-via-github-action"
steps:
- name: "Create Release"
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "${{ env.PROJECT }}${{ env.PUBLISH_VERSION }}",
"target_commitish": "${{ env.BRANCH }}",
"name": "${{ env.PROJECT }}${{ env.PUBLISH_VERSION }}",
"body": "",
"draft": true,
"prerelease": false
}' \
https://api.github.com/repos/${{ github.repository }}/releases