All checks were successful
Generate Vendor Dependencies / vendor-dependencies (push) Successful in 3s
137 lines
5.8 KiB
YAML
137 lines
5.8 KiB
YAML
name: Generate Vendor Dependencies
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
vendor-dependencies:
|
|
runs-on: tumbleweed
|
|
if: "!contains(github.event.head_commit.message, '[skip-vendor]') && github.actor != 'gitea-actions[bot]'"
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN || github.token }}
|
|
fetch-depth: 2
|
|
|
|
- name: Check for changes in matugen.spec
|
|
id: should-version-check
|
|
run: |
|
|
# Check if matugen.spec has version changes or force update
|
|
if git diff HEAD~1 HEAD --name-only | grep -q "matugen.spec" || [[ "${{ github.event.head_commit.message }}" == *"[force-vendor]"* ]]; then
|
|
echo "check_needed=true" >> $GITHUB_OUTPUT
|
|
echo "Mutagen spec file changed. We should check if the version has changed."
|
|
else
|
|
echo "check_needed=false" >> $GITHUB_OUTPUT
|
|
echo "No version changes in matugen.spec"
|
|
fi
|
|
|
|
- name: Install awk
|
|
if: steps.should-version-check.outputs.check_needed == 'true'
|
|
run: zypper --non-interactive install gawk
|
|
|
|
- name: Check for version changes in matugen.spec
|
|
if: steps.should-version-check.outputs.check_needed == 'true'
|
|
id: should-update
|
|
run: |
|
|
current_version=$(grep "^Version:" matugen.spec | awk '{print $2}')
|
|
previous_version=$(git show HEAD~1:matugen.spec | grep "^Version:" | awk '{print $2}')
|
|
if [[ "$current_version" != "$previous_version" ]] || [[ "${{ github.event.head_commit.message }}" == *"[force-vendor]"* ]]; then
|
|
echo "update_needed=true" >> $GITHUB_OUTPUT
|
|
echo "version=$current_version" >> $GITHUB_OUTPUT
|
|
echo "Version changed from $previous_version to $current_version"
|
|
else
|
|
echo "update_needed=false" >> $GITHUB_OUTPUT
|
|
echo "Version unchanged: $current_version"
|
|
fi
|
|
|
|
- name: Download matugen repository
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: |
|
|
# Remove existing matugen directory if it exists
|
|
rm -rf matugen-src
|
|
|
|
# Clone the repository with the specific version tag
|
|
git clone --depth 1 --branch "v${{ steps.should-update.outputs.version }}" \
|
|
https://github.com/InioX/matugen.git matugen-src
|
|
|
|
echo "Downloaded matugen v${{ steps.should-update.outputs.version }}"
|
|
|
|
- name: Install cargo-vendor
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: zypper --non-interactive install cargo-vendor-filterer cargo git-lfs
|
|
|
|
- name: Generate vendor directory
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: |
|
|
cd matugen-src
|
|
|
|
# Clean any existing vendor directory
|
|
rm -rf vendor/
|
|
|
|
# Generate fresh vendor directory
|
|
cargo vendor vendor --versioned-dirs > .cargo/config.toml
|
|
|
|
- name: Create vendor archive
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: |
|
|
cd matugen-src
|
|
|
|
# Remove old archive if it exists
|
|
rm -f vendor.tar.zst
|
|
|
|
# Create compressed archive
|
|
tar --zstd -cf vendor.tar.zst vendor/ .cargo/config.toml
|
|
|
|
echo "Created vendor archive: $(du -h vendor.tar.zst)"
|
|
|
|
- name: Generate _service file
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: |
|
|
cat > _service << 'EOF'
|
|
<services>
|
|
<service name="obs_scm">
|
|
<param name="scm">git</param>
|
|
<param name="url">https://github.com/InioX/matugen.git</param>
|
|
<param name="revision">v${{ steps.should-update.outputs.version }}</param>
|
|
<param name="versionformat">@PARENT_TAG@</param>
|
|
<param name="versionrewrite-pattern">v(.*)</param>
|
|
<param name="changesgenerate">enable</param>
|
|
</service>
|
|
<service name="tar" mode="buildtime"/>
|
|
</services>
|
|
EOF
|
|
|
|
- name: Configure git
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: |
|
|
git config --local user.email "action@gitea.local"
|
|
git config --local user.name "Gitea Actions Bot"
|
|
|
|
- name: Commit vendor archive
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: |
|
|
mv matugen-src/vendor.tar.zst matugen-src/.cargo .
|
|
|
|
# Add the vendor archive and service files to git
|
|
git add vendor.tar.zst _service
|
|
|
|
# Create commit message with details
|
|
commit_msg="chore: update vendor dependencies archive [skip-vendor]
|
|
|
|
- Generated from matugen v${{ steps.should-update.outputs.version }}
|
|
|
|
This commit was auto-generated by Gitea Actions."
|
|
|
|
git commit -m "$commit_msg"
|
|
|
|
- name: Push changes
|
|
if: steps.should-update.outputs.update_needed == 'true'
|
|
run: |
|
|
# Push to the current branch
|
|
git push origin HEAD:${{ github.ref_name }}
|