From e879007d98b5e30eeefa0616afabf5bba43316c9 Mon Sep 17 00:00:00 2001 From: Simon Baynes Date: Wed, 6 Dec 2023 17:12:00 +0000 Subject: [PATCH] Upgrade to .Net 8 - Move to GitHub Actions (Closes #329) - Add labeller workflow (Closes #328) Closes #326 --- .cm/gitstream.cm | 8 --- .github/dependabot.yml | 8 +++ .github/labels.yml | 66 ++++++++++++++++++ .github/workflows/blocked-issue.yml | 36 ++++++++++ .github/workflows/branch-develop.yml | 26 +++++++ .github/workflows/branch-feature.yml | 36 ++++++++++ .github/workflows/branch-hotfix.yml | 63 +++++++++++++++++ .github/workflows/branch-master.yml | 53 +++++++++++++++ .github/workflows/branch-release.yml | 29 ++++++++ .../workflows/completed-feature-workflow.yml | 24 +++++++ .github/workflows/draft-new-release.yml | 67 +++++++++++++++++++ .../in-progress-feature-workflow.yml | 23 +++++++ .github/workflows/label-configurer.yml | 20 ++++++ .github/workflows/new-issue-workflow.yml | 15 +++++ .github/workflows/step-build.yml | 60 +++++++++++++++++ .github/workflows/step-check-markdown.yml | 12 ++++ .github/workflows/step-publish-package.yml | 37 ++++++++++ .github/workflows/step-publish.yml | 25 +++++++ .github/workflows/step-tag-release.yml | 20 ++++++ .github/workflows/step-version.yml | 66 ++++++++++++++++++ .github/workflows/test-dependabot.yml | 21 ++++++ CHANGELOG.md | 8 +++ Html2Markdown.sln | 18 +++++ appveyor.yml | 47 ------------- build.cake | 59 ++++++++++++++++ semver.json | 6 ++ src/Html2Markdown/Html2Markdown.csproj | 2 +- .../Html2Markdown.Test.csproj | 3 +- 28 files changed, 801 insertions(+), 57 deletions(-) create mode 100644 .github/labels.yml create mode 100644 .github/workflows/blocked-issue.yml create mode 100644 .github/workflows/branch-develop.yml create mode 100644 .github/workflows/branch-feature.yml create mode 100644 .github/workflows/branch-hotfix.yml create mode 100644 .github/workflows/branch-master.yml create mode 100644 .github/workflows/branch-release.yml create mode 100644 .github/workflows/completed-feature-workflow.yml create mode 100644 .github/workflows/draft-new-release.yml create mode 100644 .github/workflows/in-progress-feature-workflow.yml create mode 100644 .github/workflows/label-configurer.yml create mode 100644 .github/workflows/new-issue-workflow.yml create mode 100644 .github/workflows/step-build.yml create mode 100644 .github/workflows/step-check-markdown.yml create mode 100644 .github/workflows/step-publish-package.yml create mode 100644 .github/workflows/step-publish.yml create mode 100644 .github/workflows/step-tag-release.yml create mode 100644 .github/workflows/step-version.yml create mode 100644 .github/workflows/test-dependabot.yml create mode 100644 CHANGELOG.md delete mode 100644 appveyor.yml create mode 100644 build.cake create mode 100644 semver.json diff --git a/.cm/gitstream.cm b/.cm/gitstream.cm index 0bebbe49..d25c2b87 100644 --- a/.cm/gitstream.cm +++ b/.cm/gitstream.cm @@ -12,14 +12,6 @@ automations: args: label: "{{ calc.etr }} min review" color: {{ 'E94637' if (calc.etr >= 20) else ('FBBD10' if (calc.etr >= 5) else '36A853') }} - - dependabot_auto_merge: - if: - - {{ pr.author | includes(term='dependabot')}} - run: - - action: merge@v1 - args: - wait_for_all_checks: true calc: etr: {{ branch | estimatedReviewTime }} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e61ae875..8743a932 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,3 +11,11 @@ updates: interval: "daily" labels: - "dependencies" + open-pull-requests-limit: 10 + + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "daily" + labels: + - "dependencies" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 00000000..44adc6f4 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,66 @@ +- name: "breaking change" + color: "ff0205" + description: "This change will require a major version bump" +- name: "bug" + color: "d73a4a" + description: "Something isn't working" +- name: "dependencies" + color: "0366d6" + description: "Pull requests that update a dependency file" +- name: "documentation" + color: "0075ca" + description: "Improvements or additions to documentation" +- name: "duplicate" + color: "cfd3d7" + description: "This issue or pull request already exists" +- name: "environment" + color: "703E17" + description: "Improvement, to infra or build environment" +- name: "feature" + color: "fbca04" + description: "A new business feature" +- name: "in progress" + color: "5ae1c2" + description: "In flight work" +- name: "next release" + color: "5319e7" + description: "Completed work that is yet to be deployed" +- name: "technical debt" + color: "c19337" + description: "An issue describing some techinal debt that needs to be addressed in the future" +- name: "to do" + color: "fbca04" + description: "Work that is yet to be started" +- name: "question" + color: "d876e3" + description: "Further information is requested" +- name: "wontfix" + color: "ffffff" + description: "The project maintainers have decided this will not be worked on" +- name: "request" + color: "0366d6" + description: "A request for a new feature or enhancement" +- name: "awaiting review" + color: "fbca04" + description: "This pull request is awaiting review" +- name: "scheme:onenote" + color: "61259f" + description: "This issue relates to the OneNote scheme" +- name: "scheme:github-flavored-markdown" + color: "000000" + description: "This issue relates to the GitHub Flavored Markdown scheme" +- name: "scheme:commonmark" + color: "07ff8f" + description: "This issue relates to the CommonMark scheme" +- name: "priority:critical" + color: "b60205" + description: "This issue is critical to the business" +- name: "priority:high" + color: "d93f0b" + description: "This issue is high priority" +- name: "priority:medium" + color: "fbca04" + description: "This issue is medium priority" +- name: "priority:low" + color: "0e8a16" + description: "This issue is low priority" \ No newline at end of file diff --git a/.github/workflows/blocked-issue.yml b/.github/workflows/blocked-issue.yml new file mode 100644 index 00000000..aa565ce8 --- /dev/null +++ b/.github/workflows/blocked-issue.yml @@ -0,0 +1,36 @@ +name: Blocked Issue Labeler + +on: + issues: + types: + - opened + - edited + issue_comment: + types: + - created + - edited + +jobs: + add-blocked-label: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Add blocked label if issue is blocked + run: | + body=$BODY + comment=$COMMENT + issue_number=${{ github.event.issue.number }} + + # if body contains "blocked" or comment contains "blocked" + # add label "blocked" + + if [[ "${body,,}" == *"blocked"* ]] || [[ "${comment,,}" == *"blocked"* ]]; then + echo "Issue is blocked" + echo "Adding blocked label" + gh issue edit $issue_number --add-label blocked + fi + env: + BODY: ${{ github.event.issue.body }} + COMMENT: ${{ github.event.comment.body }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/branch-develop.yml b/.github/workflows/branch-develop.yml new file mode 100644 index 00000000..8e6a11ea --- /dev/null +++ b/.github/workflows/branch-develop.yml @@ -0,0 +1,26 @@ +name: Deploy Develop Branch + +on: + push: + branches: + - develop + paths: + - 'src/**' + - 'test/**' + - '**.sln' + - '**.cake' + - '.github/workflows/branch-develop.yml' + - '.github/workflows/step-*.yml' + workflow_dispatch: + +jobs: + get-version: + uses: ./.github/workflows/step-version.yml + + build: + needs: [get-version] + uses: ./.github/workflows/step-build.yml + secrets: inherit + with: + version: ${{ needs.get-version.outputs.version }} + checkout-ref: ${{ github.base_ref }} diff --git a/.github/workflows/branch-feature.yml b/.github/workflows/branch-feature.yml new file mode 100644 index 00000000..2eb6a72f --- /dev/null +++ b/.github/workflows/branch-feature.yml @@ -0,0 +1,36 @@ +name: Deploy Feature Branch + +on: + pull_request: + types: [opened, synchronize] + branches: + - develop + paths: + - 'src/**' + - 'test/**' + - '**.sln' + - '**.cake' + - '.github/workflows/branch-feature.yml' + - '.github/workflows/step-*.yml' + workflow_dispatch: + +jobs: + get-version: + if: startsWith(github.head_ref, 'feature/') || github.head_ref == 'master' + uses: ./.github/workflows/step-version.yml + secrets: inherit + with: + is-pre-release: true + + build: + needs: [get-version] + uses: ./.github/workflows/step-build.yml + secrets: inherit + with: + version: ${{ needs.get-version.outputs.version }} + checkout-ref: ${{ github.head_ref }} + + check-markdown: + needs: [get-version] + uses: ./.github/workflows/step-check-markdown.yml + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/branch-hotfix.yml b/.github/workflows/branch-hotfix.yml new file mode 100644 index 00000000..61545841 --- /dev/null +++ b/.github/workflows/branch-hotfix.yml @@ -0,0 +1,63 @@ +name: Deploy HotFix Branch + +on: + pull_request: + types: [opened, synchronize] + branches: + - master + workflow_dispatch: + +jobs: + get-version: + if: startsWith(github.head_ref, 'hotfix/') + uses: ./.github/workflows/step-version.yml + + build: + needs: [get-version] + uses: ./.github/workflows/step-build.yml + secrets: inherit + with: + version: ${{ needs.get-version.outputs.version }} + checkout-ref: ${{ github.head_ref }} + + check-markdown: + needs: [get-version] + uses: ./.github/workflows/step-check-markdown.yml + secrets: inherit + + update-metadata: + if: github.event.action == 'opened' + needs: [get-version] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + - name: Increment Version + id: increment_version + run: | + echo "patch_version=$(($(cat semver.json | jq -r '.patch')+1))" > $GITHUB_OUTPUT + - name: Store New Version + uses: RadovanPelka/github-action-json@v1.0.1 + with: + path: semver.json + replaceWith: | + { + "major": "${{ needs.get-version.outputs.major }}", + "minor": "${{ needs.get-version.outputs.minor }}", + "patch": "${{ steps.increment_version.outputs.patch_version }}", + "build": "${{ github.run_number }}" + } + - name: Update changelog + uses: thomaseizinger/keep-a-changelog-new-release@1.3.0 + with: + tag: ${{ needs.get-version.outputs.major }}.${{ needs.get-version.outputs.minor }}.${{ steps.increment_version.outputs.patch_version }}.${{ github.run_number }} + - name: Commit Changes + run: | + git config --global user.name "GitHub Action Bot" + git config --global user.email "no-reply@after-life.co" + git add CHANGELOG.md semver.json + git commit --message "Bump Version to ${{ needs.get-version.outputs.major }}.${{ needs.get-version.outputs.minor }}.${{ steps.increment_version.outputs.patch_version }}.${{ github.run_number }}" + + - name: Push Version + run: git push origin ${{ github.head_ref }} \ No newline at end of file diff --git a/.github/workflows/branch-master.yml b/.github/workflows/branch-master.yml new file mode 100644 index 00000000..bc5d7611 --- /dev/null +++ b/.github/workflows/branch-master.yml @@ -0,0 +1,53 @@ +name: Deploy Master Branch + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + get-version: + uses: ./.github/workflows/step-version.yml + with: + static-build: true + + build: + needs: [get-version] + uses: ./.github/workflows/step-build.yml + secrets: inherit + with: + version: ${{ needs.get-version.outputs.version }} + checkout-ref: ${{ github.base_ref }} + + publish-to-nuget: + needs: [get-version,build] + uses: ./.github/workflows/step-publish.yml + secrets: inherit + with: + deploy-env: nuget + deploy-branch: ${{ github.base_ref }} + version: ${{ needs.get-version.outputs.version }} + + tag-release: + needs: [get-version,publish-to-nuget] + uses: ./.github/workflows/step-tag-release.yml + with: + version: ${{ needs.get-version.outputs.version }} + + merge-master-to-develop: + needs: [publish-to-nuget] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.CREATE_PR_TOKEN }} + run: | + echo -e "This PR merges the master branch back into develop.\nThis happens to ensure that the updates that happened on the release branch, i.e. CHANGELOG updates are also present on the develop branch." > msg.txt + + export msg=$(cat msg.txt) ; gh pr create \ + --head master \ + --base develop \ + --title "Merge master into develop branch" \ + --body "$msg" \ No newline at end of file diff --git a/.github/workflows/branch-release.yml b/.github/workflows/branch-release.yml new file mode 100644 index 00000000..cb48bd98 --- /dev/null +++ b/.github/workflows/branch-release.yml @@ -0,0 +1,29 @@ +name: Deploy Release Branch + +on: + pull_request: + types: [opened, synchronize] + branches: + - master + - develop + paths: + - 'src/**' + - 'test/**' + - '**.sln' + - '**.cake' + - '.github/workflows/branch-release.yml' + - '.github/workflows/step-*.yml' + workflow_dispatch: + +jobs: + get-version: + if: startsWith(github.head_ref, 'release/') + uses: ./.github/workflows/step-version.yml + + build: + needs: [get-version] + uses: ./.github/workflows/step-build.yml + secrets: inherit + with: + version: ${{ needs.get-version.outputs.version }} + checkout-ref: ${{ github.head_ref }} diff --git a/.github/workflows/completed-feature-workflow.yml b/.github/workflows/completed-feature-workflow.yml new file mode 100644 index 00000000..84c3dc07 --- /dev/null +++ b/.github/workflows/completed-feature-workflow.yml @@ -0,0 +1,24 @@ +name: Completed Feature Workflow + +on: + pull_request: + branches: [ develop ] + types: [closed] + +jobs: + update-merged-issue-issues: + if: github.event.pull_request.merged_by != '' && github.actor != 'dependabot[bot]' && startsWith(github.head_ref, 'feature/issue-') + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Extract Issue Number + shell: bash + run: echo "##[set-output name=issue;]$(echo ${{ github.event.pull_request.head.ref }} | sed 's|[^0-9]||g')" + id: extract_issue + - name: Output Issue Number + run: echo "Issue Number- ${{ steps.extract_issue.outputs.issue }}" + - name: Update Labels + run: gh issue edit ${{ steps.extract_issue.outputs.issue }} --add-label "next release" --remove-label "in progress" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml new file mode 100644 index 00000000..859b2689 --- /dev/null +++ b/.github/workflows/draft-new-release.yml @@ -0,0 +1,67 @@ +name: "Draft new production release" + +on: + workflow_dispatch: + inputs: + major_version: + description: 'The major version you want to release.' + required: true + minor_version: + description: 'The minor version you want to release.' + required: true + patch_version: + description: 'The patch version you want to release.' + required: true + +jobs: + + draft-new-release: + name: "Draft a new release" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create release branch + run: git checkout -b release/${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }} + + - name: Update Version Number + uses: RadovanPelka/github-action-json@v1.0.1 + with: + path: semver.json + replaceWith: | + { + "major": "${{ github.event.inputs.major_version }}", + "minor": "${{ github.event.inputs.minor_version }}", + "patch": "${{ github.event.inputs.patch_version }}", + "build": "${{ github.run_number }}" + } + + - name: Update changelog + uses: thomaseizinger/keep-a-changelog-new-release@1.3.0 + with: + tag: ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }} + + - name: Commit changelog and manifest files + id: make-commit + run: | + git config --global user.name "GitHub Action Bot" + git config --global user.email "no-reply@after-life.co" + git add CHANGELOG.md semver.json + git commit --message "Prepare release ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}" + + echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Push new branch + run: git push origin release/${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }} + + - name: Create pull request + env: + GH_TOKEN: ${{ secrets.CREATE_PR_TOKEN }} + run: | + echo -e "Hi @${{ github.actor }}!\n\nThis PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.\nI've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.\n\nMerging this PR will create a GitHub release and upload any assets that are created as part of the release build." > msg.txt + + export msg=$(cat msg.txt) ; gh pr create \ + --head release/${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }} \ + --base master \ + --title "Release version ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}" \ + --reviewer ${{ github.actor }} \ + --body "$msg" \ No newline at end of file diff --git a/.github/workflows/in-progress-feature-workflow.yml b/.github/workflows/in-progress-feature-workflow.yml new file mode 100644 index 00000000..b1b9126c --- /dev/null +++ b/.github/workflows/in-progress-feature-workflow.yml @@ -0,0 +1,23 @@ +name: In Progress Feature Workflow + +on: + push: + branches: + - feature/issue-* + +jobs: + update-in-progress-issues: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Extract Issue Number + shell: bash + run: echo "##[set-output name=issue;]$(echo ${GITHUB_REF#refs/heads/} | sed 's|[^0-9]||g')" + id: extract_issue + - name: Output Issue Number + run: echo "Issue Number- ${{ steps.extract_issue.outputs.issue }}" + - name: Update Labels + run: gh issue edit ${{ steps.extract_issue.outputs.issue }} --add-label "in progress" --remove-label "to do" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/label-configurer.yml b/.github/workflows/label-configurer.yml new file mode 100644 index 00000000..10528593 --- /dev/null +++ b/.github/workflows/label-configurer.yml @@ -0,0 +1,20 @@ +name: Configure GitHub Issue Labels + +on: + push: + paths: + - ".github/workflows/label-configurer.yml" + - ".github/labels.yml" + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run Labeler + uses: crazy-max/ghaction-github-labeler@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + exclude: | + *min review \ No newline at end of file diff --git a/.github/workflows/new-issue-workflow.yml b/.github/workflows/new-issue-workflow.yml new file mode 100644 index 00000000..feba4ca6 --- /dev/null +++ b/.github/workflows/new-issue-workflow.yml @@ -0,0 +1,15 @@ +name: New Issue Workflow +on: + issues: + types: + - opened + +jobs: + update-new-issues: + runs-on: ubuntu-latest + steps: + - name: Initialise Labelling + run: gh issue edit $ISSUE --add-label "to do" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.issue.html_url }} \ No newline at end of file diff --git a/.github/workflows/step-build.yml b/.github/workflows/step-build.yml new file mode 100644 index 00000000..50540f86 --- /dev/null +++ b/.github/workflows/step-build.yml @@ -0,0 +1,60 @@ +on: + workflow_call: + inputs: + version: + description: 'The version number to use for the build' + required: true + type: string + checkout-ref: + description: 'The commit SHA to checkout' + required: true + type: string + +jobs: + build-libraries: + runs-on: ubuntu-latest + steps: + - name: Log Branch + run: | + echo "Branch: ${{ inputs.checkout-ref }}" + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.checkout-ref }} + - name: Setup .NET Core + uses: actions/setup-dotnet@v3.2.0 + with: + dotnet-version: 8.0.x + - name: Restore + uses: cake-build/cake-action@v1 + with: + target: Restore + - name: Build + uses: cake-build/cake-action@v1 + with: + target: Build + arguments: | + versionNumber: ${{inputs.version}} + - name: Run tests + uses: cake-build/cake-action@v1 + env: + TestPath: /home/runner/work/Html2Markdown/Html2Markdown/test/Html2Markdown.Test/Files/ + with: + target: Test + - name: Publish Unit Test Results + if: ${{ github.actor != 'dependabot[bot]' }} + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + with: + files: "**/TestResults/*.xml" + - name: Build NuGet Package + uses: cake-build/cake-action@v1 + with: + target: Pack + arguments: | + versionNumber: ${{inputs.version}} + - name: Upload Package + if: ${{ github.actor != 'dependabot[bot]' }} + uses: actions/upload-artifact@v3 + with: + name: Html2Markdown + path: ./src/Html2Markdown/bin/Release/*.nupkg \ No newline at end of file diff --git a/.github/workflows/step-check-markdown.yml b/.github/workflows/step-check-markdown.yml new file mode 100644 index 00000000..121f6134 --- /dev/null +++ b/.github/workflows/step-check-markdown.yml @@ -0,0 +1,12 @@ +on: + workflow_call: + +jobs: + check-markdown: + runs-on: ubuntu-latest + steps: + - name: markdownlint-cli + uses: nosborn/github-action-markdown-cli@v3.3.0 + with: + files: . + config_file: .markdownlint.json diff --git a/.github/workflows/step-publish-package.yml b/.github/workflows/step-publish-package.yml new file mode 100644 index 00000000..f2dd479d --- /dev/null +++ b/.github/workflows/step-publish-package.yml @@ -0,0 +1,37 @@ +on: + workflow_call: + inputs: + deploy-env: + required: true + description: 'Environment to deploy to' + type: string + deploy-branch: + required: true + description: 'Branch to deploy' + type: string + version: + description: 'The version number to use for the build' + required: true + type: string + package-name: + description: 'The name of the package to push' + required: true + type: string + +jobs: + push-package: + runs-on: ubuntu-latest + environment: ${{ inputs.deploy-env }} + steps: + - name: Download Package + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.package-name }} + path: ./src/Html2Markdown/bin/Release + - name: Setup .NET Core + uses: actions/setup-dotnet@v3.2.0 + with: + dotnet-version: 8.0.x + - name: Push package to NuGet + run: | + dotnet nuget push $(find ./src/Html2Markdown/bin/Release/*.nupkg) --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json \ No newline at end of file diff --git a/.github/workflows/step-publish.yml b/.github/workflows/step-publish.yml new file mode 100644 index 00000000..83b3ce87 --- /dev/null +++ b/.github/workflows/step-publish.yml @@ -0,0 +1,25 @@ +on: + workflow_call: + inputs: + deploy-env: + required: true + description: 'Environment to deploy to' + type: string + deploy-branch: + required: true + description: 'Branch to deploy' + type: string + version: + description: 'The version number to use for the build' + required: true + type: string + +jobs: + publish-package: + uses: ./.github/workflows/step-publish-package.yml + secrets: inherit + with: + deploy-env: ${{ inputs.deploy-env }} + deploy-branch: ${{ inputs.deploy-branch }} + version: ${{ inputs.version }} + package-name: Html2Markdown \ No newline at end of file diff --git a/.github/workflows/step-tag-release.yml b/.github/workflows/step-tag-release.yml new file mode 100644 index 00000000..6f9b2470 --- /dev/null +++ b/.github/workflows/step-tag-release.yml @@ -0,0 +1,20 @@ +on: + workflow_call: + inputs: + version: + required: true + description: 'Version to deploy' + type: string + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Create tag + run: | + git config --global user.name "GitHub Action Bot" + git config --global user.email "no-reply@after-life.co" + git tag -a ${{ inputs.version }} -m "Version ${{ inputs.version }} created via GitHub Actions" + git push origin ${{ inputs.version }} \ No newline at end of file diff --git a/.github/workflows/step-version.yml b/.github/workflows/step-version.yml new file mode 100644 index 00000000..3e4de85f --- /dev/null +++ b/.github/workflows/step-version.yml @@ -0,0 +1,66 @@ +on: + workflow_call: + inputs: + static-build: + description: 'Should the build number come from the semver.json file?' + type: boolean + required: false + default: false + is-pre-release: + description: 'Is this a pre-release?' + type: boolean + required: false + default: false + outputs: + version: + description: 'The version of the app' + value: ${{ jobs.version-number.outputs.version }} + major: + description: 'The major version of the app' + value: ${{ jobs.version-number.outputs.major }} + minor: + description: 'The minor version of the app' + value: ${{ jobs.version-number.outputs.minor }} + patch: + description: 'The patch version of the app' + value: ${{ jobs.version-number.outputs.patch }} + build: + description: 'The patch version of the app' + value: ${{ jobs.version-number.outputs.build }} + +jobs: + version-number: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.set-version.outputs.version }} + major: ${{ steps.set-version.outputs.major }} + minor: ${{ steps.set-version.outputs.minor }} + patch: ${{ steps.set-version.outputs.patch }} + build: ${{ steps.set-version.outputs.build }} + steps: + - name: Get Code + uses: actions/checkout@v4 + - name: Get Version + id: get-version + uses: RadovanPelka/github-action-json@v1.0.1 + with: + path: 'semver.json' + - id: set-version + run: | + echo "major=${{ steps.get-version.outputs.major }}" >> $GITHUB_OUTPUT + echo "minor=${{ steps.get-version.outputs.minor }}" >> $GITHUB_OUTPUT + echo "patch=${{ steps.get-version.outputs.patch }}" >> $GITHUB_OUTPUT + + suffix="" + + if [ "${{ inputs.is-pre-release }}" == true ]; then + suffix="-alpha" + fi + + if [ "${{ inputs.static-build }}" == true ]; then + echo "version=${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}.${{ steps.get-version.outputs.build }}${suffix}" >> $GITHUB_OUTPUT + echo "build=${{ steps.get-version.outputs.build }}" >> $GITHUB_OUTPUT + else + echo "version=${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}.${{ steps.get-version.outputs.patch }}.${{ github.run_number }}${suffix}" >> $GITHUB_OUTPUT + echo "build=${{ github.run_number }}" >> $GITHUB_OUTPUT + fi \ No newline at end of file diff --git a/.github/workflows/test-dependabot.yml b/.github/workflows/test-dependabot.yml new file mode 100644 index 00000000..24fbaa02 --- /dev/null +++ b/.github/workflows/test-dependabot.yml @@ -0,0 +1,21 @@ +name: Test Dependabot PRs + +on: + pull_request_target: + types: [opened, synchronize] + branches: + - develop + workflow_dispatch: + +jobs: + get-version: + if: ${{ github.actor == 'dependabot[bot]' }} + uses: ./.github/workflows/step-version.yml + + build: + needs: [get-version] + uses: ./.github/workflows/step-build.yml + secrets: inherit + with: + version: ${{ needs.get-version.outputs.version }} + checkout-ref: ${{ github.event.pull_request.head.sha }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..715c79ed --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] \ No newline at end of file diff --git a/Html2Markdown.sln b/Html2Markdown.sln index 44d6d578..5a6a782a 100644 --- a/Html2Markdown.sln +++ b/Html2Markdown.sln @@ -10,6 +10,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0E30007D-D EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Html2Markdown.Test", "test\Html2Markdown.Test\Html2Markdown.Test.csproj", "{AA6A2578-6242-4A61-BB39-5CE31629694D}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CACEF6F3-2E2D-42F7-95D1-8D7FDBEFF56A}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + .gitmessage = .gitmessage + .markdownlint.json = .markdownlint.json + build.cake = build.cake + CHANGELOG.md = CHANGELOG.md + CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md + CONTRIBUTING.md = CONTRIBUTING.md + DOCUMENTATION.md = DOCUMENTATION.md + doxygen.config = doxygen.config + ISSUE_TEMPLATE.md = ISSUE_TEMPLATE.md + PULL_REQUEST_TEMPLATE.md = PULL_REQUEST_TEMPLATE.md + pushDocumentation.ps1 = pushDocumentation.ps1 + README.md = README.md + semver.json = semver.json + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 2786c598..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: 5.1.0.{build} -skip_tags: true -configuration: Release -image: - - Visual Studio 2022 - - Ubuntu -init: -- git config --global core.autocrlf true -install: -- ps: npm install -g markdownlint-cli@0.11.0 -build: - publish_nuget: true - verbosity: minimal -environment: - TestPathWindows: C:\projects\html2markdown\test\Html2Markdown.Test\Files\ - TestPathLinux: /home/appveyor/projects/html2markdown/test/Html2Markdown.Test/Files/ - GithubEmail: baynezy@gmail.com - GithubUsername: baynezy - GithubPersonalAccessToken: - secure: 9EkZYUVbHPWlMZLyUqjY79llLHc6DghntcHAodFfiMyOsIc4pbCNNEMv/lTi0SvJ -deploy: -- provider: NuGet - api_key: - secure: W/TxTO4Vm+ffwmerewCB2W2ZoNoX66DnORD0X2dwSoOTWk0m/mvnAayikC2U006s - on: - branch: master -build_script: - - ps: >- - markdownlint . - - dotnet restore - - dotnet build - - dotnet pack .\src\Html2Markdown\Html2Markdown.csproj -c $env:CONFIGURATION /p:PackageVersion=$env:APPVEYOR_BUILD_VERSION -test_script: - - ps: >- - if ($isLinux) { - $env:TestPath = $env:TestPathLinux - } else { - $env:TestPath = $env:TestPathWindows - } - dotnet test .\test\Html2Markdown.Test\Html2Markdown.Test.csproj --logger "trx;LogFileName=results.trx" -on_finish: - - ps: ./uploadTestResults.ps1 -artifacts: -- path: src\Html2Markdown\bin\Release\*.nupkg \ No newline at end of file diff --git a/build.cake b/build.cake new file mode 100644 index 00000000..5d029c29 --- /dev/null +++ b/build.cake @@ -0,0 +1,59 @@ +var target = Argument("target", "Test"); +var configuration = Argument("configuration", "Release"); +var versionNumber = Argument("versionNumber", "0.1.0"); +var projectName = "Html2Markdown"; +var solutionFolder = "./"; + +Task("Clean") + .Does(() => + { + // Clean solution + DotNetClean(solutionFolder); + }); + +Task("Restore") + .Does(() => + { + // Restore NuGet packages + DotNetRestore(solutionFolder); + }); + +Task("Build") + .Does(() => + { + // Build solution + DotNetBuild(solutionFolder, new DotNetBuildSettings + { + NoRestore = true, + Configuration = configuration, + ArgumentCustomization = args => args.Append("/p:Version=" + versionNumber) + }); + }); + +Task("Test") + .Does(() => + { + // Run tests + DotNetTest(solutionFolder, new DotNetTestSettings + { + NoRestore = true, + NoBuild = true, + Configuration = configuration, + Loggers = new string[] { "junit;LogFileName=results.xml" } + }); + }); + +Task("Pack") + .Does(() => + { + // Publish solution + DotNetPack(solutionFolder, new DotNetPackSettings + { + NoRestore = true, + NoBuild = true, + Configuration = configuration, + ArgumentCustomization = args => args.Append("/p:PackageVersion=" + versionNumber) + }); + }); + +RunTarget(target); \ No newline at end of file diff --git a/semver.json b/semver.json new file mode 100644 index 00000000..bba776b1 --- /dev/null +++ b/semver.json @@ -0,0 +1,6 @@ +{ + "major": "5", + "minor": "1", + "patch": "0", + "build": "0" +} \ No newline at end of file diff --git a/src/Html2Markdown/Html2Markdown.csproj b/src/Html2Markdown/Html2Markdown.csproj index c619218f..321ba852 100644 --- a/src/Html2Markdown/Html2Markdown.csproj +++ b/src/Html2Markdown/Html2Markdown.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net5.0;net6.0 + net7.0;net8.0 Simon Baynes https://www.apache.org/licenses/LICENSE-2.0 https://github.com/baynezy/Html2Markdown diff --git a/test/Html2Markdown.Test/Html2Markdown.Test.csproj b/test/Html2Markdown.Test/Html2Markdown.Test.csproj index 9c4203e1..196da5b5 100644 --- a/test/Html2Markdown.Test/Html2Markdown.Test.csproj +++ b/test/Html2Markdown.Test/Html2Markdown.Test.csproj @@ -1,10 +1,11 @@ - net5.0;net6.0 + net7.0;net8.0 +