From 8f4bbfc82a1f5a5193a60bd2c84f3bd3f9e14c73 Mon Sep 17 00:00:00 2001 From: Paulov Date: Mon, 4 Dec 2023 08:54:19 +0000 Subject: [PATCH] Add CI Workflow & Change Release Workflow --- .github/workflows/CI.yml | 18 +++++ .github/workflows/pre-release.yml | 115 ------------------------------ .github/workflows/release.yml | 22 +++--- 3 files changed, 28 insertions(+), 127 deletions(-) create mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/pre-release.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..f7661273 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,18 @@ +name: Node.js CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.15.0' + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml deleted file mode 100644 index 789e05d7..00000000 --- a/.github/workflows/pre-release.yml +++ /dev/null @@ -1,115 +0,0 @@ -name: Pre-Release -on: - workflow_dispatch: - inputs: - semver-type: - description: 'Can be one of [major,minor,patch]. CAUTION: This will enforce a new pre-release with the specified semantic version type bumped.' - required: false -env: - NODE_VERSION: 16 - PAULOV_BOT_NAME: "Paulov Bot" - PAULOV_BOT_EMAIL: "Paulov-bot " - RELEASE_NOTES_FILE: "RELEASE-BODY.md" - PRERELEASE_KEYWORD: "pre" -defaults: - run: - shell: bash -jobs: - pre-release: - name: Pre-Release - runs-on: ubuntu-20.04 - steps: - - name: Check SemVer input - env: - SEMVER_TYPE: ${{ github.event.inputs.semver-type }} - run: | - if [[ ! -z "$SEMVER_TYPE" ]]; then - echo "SemVer Type is defined. Checking for valid SemVer type..." - if [[ "$SEMVER_TYPE" == "major" ]] || [[ "$SEMVER_TYPE" == "minor" ]] || [[ "$SEMVER_TYPE" == "patch" ]]; then - echo "::notice::SemVer Type is correctly set to $SEMVER_TYPE! Continuing with this version bump..." - else - echo "::error::ERROR: Enforced SemVer does not match any of [major,minor,patch]!" - echo "Exiting..." - exit 1 - fi - else - echo "::notice::No SemVer type defined, continuing with auto generated version number..." - fi - - - name: Checkout repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - - - name: Configure Git - env: - PAULOV_BOT_NAME: ${{ env.PAULOV_BOT_NAME }} - PAULOV_BOT_EMAIL: ${{ env.PAULOV_BOT_EMAIL }} - run: | - git config user.name "$PAULOV_BOT_NAME" - git config user.email "$PAULOV_BOT_EMAIL" - - - name: Prepare GitHub Release Notes - env: - SEMVER_TYPE: ${{ github.event.inputs.semver-type }} - run: | - if [[ -z "$SEMVER_TYPE" ]]; then - npx standard-version@^9.3.1 \ - --prerelease "${{ env.PRERELEASE_KEYWORD }}" \ - -i "${{ env.RELEASE_NOTES_FILE }}" \ - --skip.commit \ - --skip.tag \ - --header "" \ - --release-as "$SEMVER_TYPE" - else - npx standard-version@^9.3.1 \ - --prerelease "${{ env.PRERELEASE_KEYWORD }}" \ - -i "${{ env.RELEASE_NOTES_FILE }}" \ - --skip.commit \ - --skip.tag \ - --header "" - fi - - - name: Enhance Release Notes with Build Metadata - run: | - echo "#### Build Information" >> "${{ env.RELEASE_NOTES_FILE }}" - echo "" >> "${{ env.RELEASE_NOTES_FILE }}" - echo "**GitHub Actions Run:** $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> "${{ env.RELEASE_NOTES_FILE }}" - - - name: Create pre-release package - id: create-release-package - env: - SEMVER_TYPE: ${{ github.event.inputs.semver-type }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - echo "🚀 Creating pre-release package now..." - - if [[ ! -z "$SEMVER_TYPE" ]]; then - npx standard-version@^9.3.1 \ - --release-as "$SEMVER_TYPE" \ - --prerelease "${{ env.PRERELEASE_KEYWORD }}" \ - --skip.commit \ - --skip.changelog - else - npx standard-version@^9.3.1 \ - --prerelease "${{ env.PRERELEASE_KEYWORD }}" \ - --skip.commit \ - --skip.changelog - fi - - echo "::set-output name=tag-name::$(git describe --tags --abbrev=0)" - echo "⚡️ Pushing changes to remote repository..." - git push --follow-tags - - - name: Create GitHub Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_TAG: ${{ steps.create-release-package.outputs.tag-name }} - run: | - gh release create "$RELEASE_TAG" --prerelease --draft --notes-file "${{ env.RELEASE_NOTES_FILE }}" --title "$RELEASE_TAG" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e1336d20..031fefa2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,8 @@ on: - push: - branches: - - 'master' + workflow_dispatch: name: Create Release - - jobs: build: permissions: write-all @@ -20,18 +16,20 @@ jobs: uses: actions/checkout@v2 with: ref: 'master' + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm i + - run: npm run build - name: Create Release id: create_release - uses: actions/create-release@latest + uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} - release_name: ${{ github.event.repository.updated_at }} draft: true prerelease: false - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - run: npm i + generate_release_notes: true +