From da2d9685a35f6f5409facebf14d8646ea5e9b646 Mon Sep 17 00:00:00 2001 From: Rafael Sene Date: Thu, 27 Apr 2023 16:28:32 -0300 Subject: [PATCH] Update the build workflow --- .github/workflows/build-pdf.yml | 45 ++++++++++++++++++++++------ .github/workflows/create-release.yml | 40 ------------------------- 2 files changed, 36 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/create-release.yml diff --git a/.github/workflows/build-pdf.yml b/.github/workflows/build-pdf.yml index 8f34559..7cbbb36 100644 --- a/.github/workflows/build-pdf.yml +++ b/.github/workflows/build-pdf.yml @@ -1,13 +1,21 @@ -name: Build Specification +name: Build Document PDF on: workflow_dispatch: - push: - branches: - - main - pull_request: - branches: - - main + inputs: + release_type: + description: 'Release type (draft or regular)' + required: true + type: string + default: 'regular' + version: + description: 'Release version, e.g. X.Y.Z:' + required: true + type: string + target_branch: + description: 'Target branch to run the workflow on' + required: true + default: 'main' jobs: build: @@ -24,11 +32,14 @@ jobs: - name: Pull Container run: | docker pull riscvintl/riscv-docs-base-container-image:latest + # Build PDF file using the container - name: Build Files + id: build_files run: | docker run --rm -v ${{ github.workspace }}:/build riscvintl/riscv-docs-base-container-image:latest \ /bin/sh -c 'make' + # Set the short SHA and repo name for use in artifact names - name: Set short SHA and repo name run: | @@ -39,6 +50,22 @@ jobs: - name: Upload Build Artifact uses: actions/upload-artifact@v3 with: - name: ${{ env.REPO_NAME }}-${{ env.SHORT_SHA }}.pdf - path: ${{ github.workspace }}/*.pdf + name: ${{ env.REPO_NAME }}-${{ env.SHORT_SHA }} + path: | + ${{ github.workspace }}/*.pdf retention-days: 7 + + - name: Create Release + if: steps.build_files.outcome == 'success' && github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != '' + uses: softprops/action-gh-release@v1 + with: + draft: ${{ github.event.inputs.release_type == 'draft' }} + tag_name: v${{ github.event.inputs.version }} + name: ${{ env.CURRENT_DATE }} + body: | + This release was created by: ${{ github.event.sender.login }} + Release Notes: ${{ github.event.inputs.release_notes }} + files: | + ${{ github.workspace }}/*.pdf + env: + GITHUB_TOKEN: ${{ secrets.GHTOKEN }} diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index 90776df..0000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Create Release - -on: - workflow_dispatch: - inputs: - version: - description: 'Release version, e.g. X.Y.Z:' - required: true - type: string - prerelease: - description: 'Tag as a pre-release?' - required: false - type: boolean - default: true - draft: - description: 'Create release as a draft?' - required: false - type: boolean - default: false - -jobs: - build: - uses: ./.github/workflows/build-pdf.yml - release: - runs-on: ubuntu-latest - needs: build - steps: - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: ${{ needs.build.outputs.pdf-name }} - - name: Create Release - uses: softprops/action-gh-release@v1 - with: - files: ${{ needs.build.outputs.pdf-name }} - tag_name: v${{ github.event.inputs.version }} - name: Release ${{ github.event.inputs.version }} - draft: ${{ github.event.inputs.draft }} - prerelease: ${{ github.event.inputs.prerelease }} - body: "This release includes the document in PDF format." \ No newline at end of file