-
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (106 loc) · 5.06 KB
/
upstream-update.yml
File metadata and controls
130 lines (106 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Fetch Latest Bandicoot Release
on:
workflow_dispatch: # Manual trigger
schedule:
- cron: '0 17 * * *' # Runs daily at 10 AM PDT (5 PM UTC)
jobs:
fetch-gitlab-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up GitLab API access
id: setup
run: |
echo "GITLAB_API_URL=https://gitlab.com/api/v4" >> $GITHUB_ENV
echo "GITLAB_PROJECT_ID=bandicoot-lib/bandicoot-code" >> $GITHUB_ENV
- name: Get current version
id: current-version
run: |
if [ -f "inst/version.txt" ]; then
CURRENT_VERSION=$(cat inst/version.txt)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
else
echo "current_version=none" >> $GITHUB_OUTPUT
echo "No current version found"
fi
- name: Fetch latest release from GitLab
id: get-version
run: |
# Fetch latest release from GitLab API
RESPONSE=$(curl -s "$GITLAB_API_URL/projects/$(echo $GITLAB_PROJECT_ID | sed 's/\//%2F/g')/releases" \
-H "PRIVATE-TOKEN: ${{ secrets.GITLAB_API_TOKEN }}")
# Extract the latest version and download URL
LATEST_VERSION=$(echo $RESPONSE | jq -r '.[0].tag_name')
DOWNLOAD_URL=$(echo $RESPONSE | jq -r '.[0].assets.sources[0].url')
# Remove 'v' prefix if present
LATEST_VERSION=${LATEST_VERSION#v}
# Set as output and environment variable
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "download_url=$DOWNLOAD_URL" >> $GITHUB_OUTPUT
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
# Log the fetched version
echo "Latest version: $LATEST_VERSION"
echo "Download URL: $DOWNLOAD_URL"
- name: Check if update is needed
id: check-update
run: |
if [ "${{ steps.current-version.outputs.current_version }}" != "${{ steps.get-version.outputs.version }}" ]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
echo "Update needed: Current version ${{ steps.current-version.outputs.current_version }} differs from latest ${{ steps.get-version.outputs.version }}"
else
echo "update_needed=false" >> $GITHUB_OUTPUT
echo "No update needed: Current version matches latest version"
fi
- name: Download and extract release
if: steps.check-update.outputs.update_needed == 'true'
run: |
# Create temporary directory
mkdir -p temp_download
# Download the zip file
curl -L "${{ steps.get-version.outputs.download_url }}" -o temp_download/release.zip
# Extract the zip file
unzip temp_download/release.zip -d temp_download
# Find the bandicoot directory
BANDICOOT_DIR=$(find temp_download -name "bandicoot-code-*" -type d | head -1)
echo "Found Bandicoot directory: $BANDICOOT_DIR"
# Check if include directory exists
if [ -d "$BANDICOOT_DIR/include" ]; then
echo "Found include directory at $BANDICOOT_DIR/include"
# Create destination directory if it doesn't exist
mkdir -p inst/include
# Copy the include directory contents
cp -r $BANDICOOT_DIR/include/* inst/include/
# List copied files for verification
echo "Copied files to inst/include:"
ls -la inst/include/
else
echo "Error: include directory not found in $BANDICOOT_DIR"
echo "Directory contents:"
ls -la $BANDICOOT_DIR
exit 1
fi
# Clean up
rm -rf temp_download
# Update version file
mkdir -p inst
echo "${{ steps.get-version.outputs.version }}" > inst/version.txt
- name: Create Pull Request
if: steps.check-update.outputs.update_needed == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update to Bandicoot release ${{ steps.get-version.outputs.version }}"
title: "Update Bandicoot to version ${{ steps.get-version.outputs.version }}"
body: |
This PR updates the Bandicoot library from version ${{ steps.current-version.outputs.current_version }} to ${{ steps.get-version.outputs.version }}.
Changes:
- Updated `inst/include/` files from the latest release
- Updated version in `inst/version.txt`
This PR was automatically generated by the Fetch Latest Bandicoot Release workflow.
branch: update-bandicoot-${{ steps.get-version.outputs.version }}
base: main
labels: |
dependency
automated pr