From 9704dcf3cfca83a7c915a3f9f79f86396fd603da Mon Sep 17 00:00:00 2001 From: H1rono Date: Mon, 15 Apr 2024 22:22:40 +0900 Subject: [PATCH] :sparkles: Create draft release on new tag pushed --- .github/workflows/release.yml | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..33ceb19 --- /dev/null +++ b/.github/workflows/release.yml @@ -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