-
Notifications
You must be signed in to change notification settings - Fork 14
182 lines (150 loc) · 5.53 KB
/
build-and-snapshot.yml
File metadata and controls
182 lines (150 loc) · 5.53 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Build, Test and Snapshot Release
on:
push:
branches:
- main
- master
pull_request:
schedule:
- cron: "0 0 * * 0" # Weekly on Sunday at midnight
workflow_dispatch: # Allows manual triggering
jobs:
lint-and-test-python:
name: Lint Python Test Suite
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Setup Python test environment
run: |
cd test
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Run Python linting
run: |
cd test
source venv/bin/activate
../scripts/lint-python.sh ci
build:
name: Build and Test Go Plugin
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: [">=1.23.5"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: go mod tidy -e || true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
- name: Lint and format Go files
run: ./scripts/lint-go.sh ci
- name: Build binary
run: |
echo "🔨 Building binary..."
python3 .github/workflows/build.py
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cf-cli-java-plugin-${{ matrix.os }}
path: dist/
release:
name: Create Snapshot Release
needs: [build, lint-and-test-python]
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && (needs.lint-and-test-python.result == 'success' || needs.lint-and-test-python.result == 'skipped')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Python dependencies for plugin repo generation
run: |
python -m pip install --upgrade pip
pip install PyYAML
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/
- name: Combine all artifacts
run: |
mkdir -p dist
mv dist/*/* dist/ || true
- name: Generate plugin repository YAML for snapshot
env:
GITHUB_REF_NAME: snapshot
run: |
echo "📝 Generating plugin repository YAML file..."
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip
pip install PyYAML requests
python3 .github/workflows/generate_plugin_repo.py $GITHUB_REF_NAME
echo "✅ Plugin repository YAML generated"
- name: Generate timestamp
id: timestamp
run: echo "timestamp=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
- uses: thomashampson/delete-older-releases@main
with:
keep_latest: 0
delete_tag_regex: snapshot
prerelease_only: true
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete and regenerate tag snapshot
run: |
echo "Deleting existing snapshot tag..."
git tag -d snapshot || true
git push origin :snapshot || true
echo "Regenerating snapshot tag..."
git tag snapshot
git push origin snapshot --force
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
plugin-repo-entry.yml
plugin-repo-summary.txt
prerelease: false
draft: false
tag_name: snapshot
body: |
This is a snapshot release of the cf-cli-java-plugin.
It includes the latest changes and is not intended for production use.
Please test it and provide feedback.
**Build Timestamp**: ${{ steps.timestamp.outputs.timestamp }}
## Installation
Download the current snapshot release and install manually:
```sh
# on Mac arm64
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/snapshot/cf-cli-java-plugin-macos-arm64
# on Windows x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/snapshot/cf-cli-java-plugin-windows-amd64
# on Linux x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/snapshot/cf-cli-java-plugin-linux-amd64
```
**Note:** On Linux and macOS, if you get a permission error, run `chmod +x [cf-cli-java-plugin]` on the plugin binary.
On Windows, the plugin will refuse to install unless the binary has the `.exe` file extension.
You can verify that the plugin is successfully installed by looking for `java` in the output of `cf plugins`.
name: Snapshot Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}