Skip to content

Commit

Permalink
Merge pull request #76 from RecklessBoon/main
Browse files Browse the repository at this point in the history
Fixes workflow & cleans repo
  • Loading branch information
manuelmayer-dev authored Oct 8, 2022
2 parents 970b0f6 + acfb611 commit 54ff87b
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 74 deletions.
89 changes: 16 additions & 73 deletions .github/workflows/extension_upsert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ jobs:

- name: Get manifest details
run: |
if [ ! -d temp ]; then mkdir temp; fi
cd temp
rm -rf ../temp
mkdir ../temp
cd ../temp
git clone "${{ inputs.github_http_url }}" .
git checkout "${{ inputs.commit_ref }}"
ext_type=$(git cat-file -p HEAD:ExtensionManifest.json | jq -r '[.type][0]')
package_id=$(git cat-file -p HEAD:ExtensionManifest.json | jq -r '[.packageId][0]')
if [ $ext_type != "Plugin" ]; then ext_type='IconPack'; fi
echo "ext_type=$ext_type" >> $GITHUB_ENV
echo "package_id=$package_id" >> $GITHUB_ENV
cd ..
cd ${{ github.workspace }}
- name: Get Output Path
id: ext_type_check
Expand All @@ -46,12 +47,10 @@ jobs:
fi
- name: Clean branch
run: |
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
shell: bash
run: |
chmod +x ./bin/clean_working_tree.sh
./bin/clean_working_tree.sh
- name: Add Submodule (If Needed)
id: add_submodule
Expand All @@ -67,73 +66,17 @@ jobs:
cd "./${{ env.output_path }}/${{ env.package_id }}"
git gc --prune=now
git remote prune origin
git fetch origin "${{ inputs.commit_ref }}":"${{ inputs.commit_ref }}"
git checkout "${{ inputs.commit_ref }}"
git branch -D ${{ inputs.commit_ref }} || true
git tag -d ${{ inputs.commit_ref }} || true
git fetch origin --tags "${{ inputs.commit_ref }}"
git checkout FETCH_HEAD
cd ../..
- name: Sanity Check
run: |
cd "./${{ env.output_path }}/${{ env.package_id }}"
if [ ! -z "${{ env.current_hash }}" ]; then
result=0
# ExtensionManifest.json check
old_manifest_version=$(git cat-file -p ${{ env.current_hash }}:ExtensionManifest.json | jq -r '[.version][0]')
new_manifest_version=$(git cat-file -p HEAD:ExtensionManifest.json | jq -r '[.version][0]')
if [ $old_manifest_version == $new_manifest_version ]; then
echo "::error::ExtensionManifest.json 'version' key was not updated"
result=1
fi
if [ ${{ env.ext_type }} = 'Plugin' ]; then
# csproj check
old_csproj_version=$(git cat-file -p ${{ env.current_hash }}:$(ls *.csproj | head -n 1) | grep -oPm1 "(?<=<Version>)[^<]+")
new_csproj_version=$(git cat-file -p HEAD:$(ls *.csproj | head -n 1) | grep -oPm1 "(?<=<Version>)[^<]+")
if [ $old_csproj_version == $new_csproj_version ]; then
echo "::error::csproj file 'version' node was not updated"
result=1
fi
# ExntensionManifest <-> csproj check
if [ ! -z $new_manifest_version ] && [ ! -z $new_csproj_version ] && [ $new_manifest_version != $new_csproj_version ]; then
echo "::error::ExtensionManifest.json 'version' token does not match the csproj file's 'Version' node"
result=1
fi
fi
if [ $result -ne 0 ]; then
exit 1
fi
else
result=0
# Manifest check
manifest_version="$(git cat-file -p HEAD:ExtensionManifest.json | jq -r '[.version][0]')"
if [ -z manifest_version ]; then
echo "::error::ExtensionManifest.json 'version' key does not exist"
result=1
fi
if [ ${{ env.ext_type }} = 'Plugin' ]; then
# csproj check
csproj_version="$(git cat-file -p HEAD:$(ls *.csproj | head -n 1) | grep -oPm1 "(?<=<Version>)[^<]+")"
if [ -z csproj_version ]; then
echo "::error::csproj file 'version' key does not exist"
result=1
fi
# ExntensionManifest <-> csproj check
if [ ! -z $manifest_version ] && [ ! -z $csproj_version ] && [ $manifest_version != $csproj_version ]; then
echo "::error::ExtensionManifest.json 'version' token does not match the csproj file's 'Version' node"
result=1
fi
fi
if [ $result -ne 0 ]; then
exit 1
fi
fi
cd ../..
shell: bash
run: |
chmod +x ./bin/sanity_check.sh
./bin/sanity_check.sh
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
Expand Down
6 changes: 6 additions & 0 deletions bin/clean_working_tree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
62 changes: 62 additions & 0 deletions bin/sanity_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
cd "./${{ env.output_path }}/${{ env.package_id }}"
if [ ! -z "${{ env.current_hash }}" ]; then
result=0

# ExtensionManifest.json check
old_manifest_version=$(git cat-file -p ${{ env.current_hash }}:ExtensionManifest.json | jq -r '[.version][0]')
new_manifest_version=$(git cat-file -p HEAD:ExtensionManifest.json | jq -r '[.version][0]')
if [ $old_manifest_version == $new_manifest_version ]; then
echo "::error::ExtensionManifest.json 'version' key was not updated"
result=1
fi

if [ ${{ env.ext_type }} = 'Plugin' ]; then
# csproj check
old_csproj_version=$(git cat-file -p ${{ env.current_hash }}:$(ls *.csproj | head -n 1) | grep -oPm1 "(?<=<Version>)[^<]+")
new_csproj_version=$(git cat-file -p HEAD:$(ls *.csproj | head -n 1) | grep -oPm1 "(?<=<Version>)[^<]+")
if [ $old_csproj_version == $new_csproj_version ]; then
echo "::error::csproj file 'version' node was not updated"
result=1
fi

# ExntensionManifest <-> csproj check
if [ ! -z $new_manifest_version ] && [ ! -z $new_csproj_version ] && [ $new_manifest_version != $new_csproj_version ]; then
echo "::error::ExtensionManifest.json 'version' token does not match the csproj file's 'Version' node"
result=1
fi
fi

if [ $result -ne 0 ]; then
exit 1
fi
else
result=0

# Manifest check
manifest_version="$(git cat-file -p HEAD:ExtensionManifest.json | jq -r '[.version][0]')"
if [ -z manifest_version ]; then
echo "::error::ExtensionManifest.json 'version' key does not exist"
result=1
fi

if [ ${{ env.ext_type }} = 'Plugin' ]; then
# csproj check
csproj_version="$(git cat-file -p HEAD:$(ls *.csproj | head -n 1) | grep -oPm1 "(?<=<Version>)[^<]+")"
if [ -z csproj_version ]; then
echo "::error::csproj file 'version' key does not exist"
result=1
fi

# ExntensionManifest <-> csproj check
if [ ! -z $manifest_version ] && [ ! -z $csproj_version ] && [ $manifest_version != $csproj_version ]; then
echo "::error::ExtensionManifest.json 'version' token does not match the csproj file's 'Version' node"
result=1
fi
fi

if [ $result -ne 0 ]; then
exit 1
fi
fi
cd ../..
1 change: 0 additions & 1 deletion temp
Submodule temp deleted from 02189c

0 comments on commit 54ff87b

Please sign in to comment.