Skip to content

Commit

Permalink
✨ Create draft release on new tag pushed
Browse files Browse the repository at this point in the history
  • Loading branch information
H1rono committed Apr 15, 2024
1 parent 65a5b7b commit 9704dcf
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
push:
tags:
- "*"

jobs:
check-main-branch:
runs-on: ubuntu-latest
outputs:
contains: ${{ steps.check.outputs.contains }}
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- id: check
run: |
branches=$(git branch --contains "$GITHUB_REF_NAME")
for branch in $branches; do
if [[ "$branch" == "main" ]]; then
echo "contains=true" >> "$GITHUB_OUTPUT"
exit 0
fi
done
echo "contains=false" >> "$GITHUB_OUTPUT"
build-book:
runs-on: ubuntu-latest
env:
# FIXME: duplicate of .github/workflows/main.yml:112
MDBOOK_VERSION: v0.4.36
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- run: |
curl -fsSL "$REPO_URL$RELEASE_DL_PATH/$MDBOOK_VERSION/$FILENAME" | tar xz
env:
REPO_URL: https://github.com/rust-lang/mdBook
RELEASE_DL_PATH: /releases/download
FILENAME: mdbook-${{ env.MDBOOK_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
- run: |
./mdbook build
tar czf book.tar.gz book
- uses: actions/upload-artifact@v4
with:
name: book-archive
path: ./book.tar.gz

create-release:
runs-on: ubuntu-latest
needs: check-main-branch
if: ${{ needs.check-main-branch.outputs.contains == 'true' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/download-artifact@v4
with:
name: book-archive
- run: |
gh release create $GITHUB_REF_NAME book.tar.gz \
-d -t $GITHUB_REF_NAME -n "" --verify-tag

0 comments on commit 9704dcf

Please sign in to comment.