-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
187 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Has Changes | ||
description: Checks if project has any changes since last release | ||
inputs: | ||
project: | ||
required: true | ||
description: "EncryptedConfigValue.Module | EncryptedConfigValue.AspNetCore" | ||
outputs: | ||
result: | ||
description: "true | false" | ||
value: "${{ steps.validate.outputs.result }}" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Validate | ||
shell: bash | ||
id: validate | ||
run: | | ||
hash_current=$(git rev-parse HEAD) | ||
echo "hash_current=$hash_current" | ||
if [ -z "$hash_current" ]; then | ||
echo "result=false" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
hash_of_last_release=$(git tag -l "${{ inputs.project }}/*" | sort -V | tail -n 1 | xargs -I {} git rev-list -n 1 {}) | ||
echo "hash_of_last_release=$hash_of_last_release" | ||
if [ -z "$hash_of_last_release" ]; then | ||
echo "result=false" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
has_differences=$(git diff --quiet "$hash_current:./${{ inputs.project }}" "$hash_of_last_release:./${{ inputs.project }}" && echo false || echo true) | ||
echo "has_differences=$has_differences" | ||
if [ -z "$has_differences" ]; then | ||
echo "result=false" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
echo "result=true" | ||
echo "result=true" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Update nuspec file | ||
description: Update .nuspec file | ||
inputs: | ||
GITHUB_TOKEN: | ||
description: 'GITHUB_TOKEN' | ||
required: true | ||
project: | ||
required: true | ||
description: "Allowed values: EncryptedConfigValue.Module | EncryptedConfigValue.AspNetCore" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup env variables | ||
shell: bash | ||
run: | | ||
TARGET_BRANCH_NAME="bot/${{ inputs.project }}/update-nuspec" | ||
echo "TARGET_BRANCH_NAME=$TARGET_BRANCH_NAME" >> $GITHUB_ENV | ||
- name: Setup git | ||
shell: bash | ||
run: | | ||
git config --global user.name "GitHub Action" | ||
git config --global user.email "action@github.com" | ||
IS_TARGET_BRANCH_EXISTS=$(git ls-remote --heads origin $TARGET_BRANCH_NAME | grep -q "refs/heads/$TARGET_BRANCH_NAME" && echo true || echo false) | ||
echo "IS_TARGET_BRANCH_EXISTS=$IS_TARGET_BRANCH_EXISTS" >> $GITHUB_ENV | ||
if [[ "$IS_TARGET_BRANCH_EXISTS" == "true" ]]; then | ||
git fetch origin $TARGET_BRANCH_NAME:$TARGET_BRANCH_NAME | ||
git checkout $TARGET_BRANCH_NAME | ||
git reset --hard origin/main | ||
else | ||
git checkout -b $TARGET_BRANCH_NAME | ||
fi | ||
- uses: ./.github/actions/setup-dotnet-action | ||
|
||
- name: Build | ||
shell: bash | ||
run: dotnet build ./EncryptedConfigValue.sln --configuration Release | ||
|
||
- name: Update ${{ inputs.project }}.nuspec | ||
shell: pwsh | ||
run: | | ||
pwsh ./Scripts/UpdateNuspec.ps1 -CsprojPath "./${{ inputs.project }}/${{ inputs.project }}.csproj" -NuspecPath "./${{ inputs.project }}/${{ inputs.project }}.nuspec" -ReadmePath "./Readme.md" | ||
- name: Commit changes | ||
shell: bash | ||
run: | | ||
git add --all . | ||
git commit -m "Update ${{ inputs.project }}.nuspec" | ||
if [[ "$IS_TARGET_BRANCH_EXISTS" == "true" ]]; then | ||
git push --force origin $TARGET_BRANCH_NAME | ||
else | ||
git push --set-upstream origin $TARGET_BRANCH_NAME | ||
fi | ||
- name: Create Pull Request | ||
shell: bash | ||
run: | | ||
pr_id=$(gh pr list --base main --head $TARGET_BRANCH_NAME --json number --jq '.[0].number') | ||
if [ -z "$pr_id" ]; then | ||
gh pr create -B main -H $TARGET_BRANCH_NAME --title 'Release ${{ inputs.project }}' --body "**⚠️ Attention: This Pull Request Will Initiate the Release Process of ${{ inputs.project }}! ⚠️**" | ||
else | ||
gh pr edit $pr_id --title 'Release ${{ inputs.project }}' --body "**⚠️ Attention: This Pull Request Will Initiate the Release Process of ${{ inputs.project }}! ⚠️**" | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.