Improve CI handling of generated script #43
This file contains hidden or 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
| name: Build 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: | |
| build: | |
| name: Build and Test on All Platforms | |
| 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@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: go mod tidy -e || true | |
| - name: Lint Go files | |
| run: go fmt ./... | |
| - name: Build binary | |
| run: python3 .github/workflows/build.py | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cf-cli-java-plugin-${{ matrix.os }} | |
| path: dist/ | |
| - name: Install cf | |
| run: | | |
| if [ "$RUNNER_OS" == "Linux" ]; then | |
| # Ubuntu installation | |
| wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo gpg --dearmor -o /usr/share/keyrings/cli.cloudfoundry.org.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/cli.cloudfoundry.org.gpg] https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list | |
| sudo apt-get update | |
| sudo apt-get install -y cf8-cli | |
| elif [ "$RUNNER_OS" == "macOS" ]; then | |
| # macOS installation | |
| brew install cloudfoundry/tap/cf-cli@8 | |
| elif [ "$RUNNER_OS" == "Windows" ]; then | |
| # Windows installation | |
| curl -L "https://packages.cloudfoundry.org/stable?release=windows64-exe&version=8&source=github-rel" -o cf8.zip | |
| unzip cf8.zip | |
| mkdir -p $HOME/bin | |
| mv cf8.exe $HOME/bin/cf.exe | |
| echo "$HOME/bin" >> $GITHUB_PATH | |
| else | |
| echo "Unsupported OS: $RUNNER_OS" | |
| exit 1 | |
| fi | |
| - name: Run 'cf java generate-alias-script' | |
| run: | | |
| make install | |
| cf java generate-alias-script > dist/script.sh | |
| - name: Upload script | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: script.sh | |
| path: dist/ | |
| release: | |
| name: Create Snapshot Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist/ # Specify the directory where artifacts will be downloaded | |
| - name: Combine all artifacts | |
| run: | | |
| mkdir -p dist | |
| mv dist/*/* dist/ || true | |
| - 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: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/* | |
| prerelease: true | |
| tag_name: snapshot | |
| overwrite: true | |
| 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. | |
| name: Snapshot Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |