#123 Introduce semantic versioning to CD workflow (#125)

* Added a versioning workflow that will determine the next version number, update the module manifest, and commit the updated file to a `version` branch.
Updated the `create-docs-pr` to create a PR from either the `docs` or `version` branch.
Minor regex fix to `cd-github-release.yml

* YAML Linter doesn't like the escape character... it's not regex afterall. (I think I knew this from a previous commit doing the same thing)

* Updating the git code to explicitly push the new tag.

* Fixing linting errors.

* Fixing linting errors.

* Separated the module versioning from the tag versioning.
Removed the tagging from the module versioning.
Added a new workflow that will tag the main branch on a pull request merge with the version inside the manifest.

* Adding "unsaved" files.

* Adding "unsaved" files, again!.

* Adding "unsaved" files, again, and again!.

* Fixing linting issues.

* Fixing the cd-create-version-tag.yml file.

* Minor grammar fix.

* Adding a newling per code review comments.

* Linting updates.

* Added .devcontainer support for megalinter (nodejs) and prettier (VSCode extenstion).
Fixed linting errors from v8r and prettier.
This commit is contained in:
marclerwick 2023-01-30 16:35:20 -08:00 коммит произвёл GitHub
Родитель 2a2f91ca05
Коммит c960ab05a2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 96 добавлений и 16 удалений

Просмотреть файл

@ -14,7 +14,8 @@
"ghcr.io/rchaganti/vsc-devcontainer-features/azurebicep:1": {},
"ghcr.io/natescherer/devcontainers-custom-features/powershell-resources:1": {
"resources": ["Az", "Pester", "platyps"]
}
},
"ghcr.io/devcontainers/features/node:1": {}
},
"settings": {},
"extensions": [
@ -22,7 +23,8 @@
"GitHub.copilot",
"ms-dotnettools.csharp",
"ms-vscode.powershell",
"ms-azuretools.vscode-docker"
"ms-azuretools.vscode-docker",
"esbenp.prettier-vscode@9.10.4"
],
"remoteUser": "vscode"
}

26
.github/workflows/cd-create-version-tag.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,26 @@
---
name: cd-create-version-tag
on: # yamllint disable-line rule:truthy
push:
branches: [main]
pull_request:
branches: [main]
jobs:
create-version-tag:
if: ${{ github.event_name == 'push' && github.event.pull_request.head.ref == 'refs/heads/version' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Retrieve Version and Create Version Tag
# I don't know why, but the first sed command adds a space to the beginning of the string so the second sed
# command removes that space.
# This will create a version tag with a leading "v" followed by the ModuleVersion value inside the quotes
# e.g., "v0.1" for ModuleVersion = "0.1"
run: |
cd ./BenchPress/Helpers/BenchPress.Azure
version=v$(sed -n 's/ModuleVersion = "\([^"]*\)"/\1/p' ./BenchPress.Azure.psd1 \
| sed -n 's/\s*//p')
git tag $version
git push origin $version

1
.github/workflows/cd-github-release.yml поставляемый
Просмотреть файл

@ -3,6 +3,7 @@ name: cd-github-release
on: # yamllint disable-line rule:truthy
push:
branches: [main]
tags:
- "v[0-9]+.[0-9]+*"

47
.github/workflows/ci-module-versioning.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,47 @@
---
name: ci-module-versioning
on: # yamllint disable-line rule:truthy
push:
branches: [main]
paths:
- "./BenchPress/Helpers/BenchPress.Azure/*"
jobs:
get-tags:
runs-on: ubuntu-latest
outputs:
Version: ${{ steps.gitversion.outputs.majorMinorPatch }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: "5.x"
- name: Checkout Latest
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.9.15
id: gitversion
update-manifest:
needs: [get-tags]
if: needs.get-tags.output.CommitsSinceVersionSource > 0
runs-on: ubuntu-latest
steps:
- name: Create and checkout new version branch
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git checkout -b version
- name: Update manifest file
run: |
sed -i 's/ModuleVersion = "[^"]*"/ModuleVersion = "${{ needs.get-tags.output.Version }}"/' \
./BenchPress/Helpers/BenchPress.Azure/BenchPress.Azure.psd1
- name: Commit changes
run: |
git add ./BenchPress/Helpers/BenchPress.Azure/BenchPress.Azure.psd1
git commit -m "version: updating version"
git push origin version

18
.github/workflows/create-automated-prs.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,18 @@
---
name: create-automated-prs
on: # yamllint disable-line rule:truthy
push:
branches:
- "docs"
- "version"
jobs:
publish-branch:
runs-on: ubuntu-latest
steps:
- name: Create pull request
run: |
gh pr create -B main -H ${{ github.ref_name }} --title 'Merge updated ${{ github.ref_name }} into main.' \
--body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

14
.github/workflows/create-docs-pr.yml поставляемый
Просмотреть файл

@ -1,14 +0,0 @@
---
name: "Create Docs PR"
on: # yamllint disable-line rule:truthy
push:
branches: [docs]
jobs:
publish-docs-branch:
runs-on: ubuntu-latest
steps:
- name: Create pull request
run: gh pr create -B main -H docs --title 'Merge updated docs into main.' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}