diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 463e2e7..eaf53d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,12 @@ on: push: tags: - 'v*' + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g., v0.1.0)' + required: true + default: 'v0.1.0' env: CARGO_TERM_COLOR: always @@ -15,14 +21,39 @@ jobs: outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set version from tag + if: startsWith(github.ref, 'refs/tags/') + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Set version from input + if: github.event_name == 'workflow_dispatch' + run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV + + - name: Create tag for manual release + if: github.event_name == 'workflow_dispatch' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if git tag -l "${{ github.event.inputs.version }}" | grep -q .; then + echo "Tag ${{ github.event.inputs.version }} already exists!" + exit 1 + fi + git tag -a "${{ github.event.inputs.version }}" -m "Release ${{ github.event.inputs.version }}" + git push origin "${{ github.event.inputs.version }}" + - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + tag_name: ${{ env.VERSION }} + release_name: Release ${{ env.VERSION }} draft: false prerelease: false