GitHub Actions: use jlumbroso/free-disk-space to free disk space #182
Workflow file for this run
This file contains 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 | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
pull_request_target: | |
types: [labeled] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.properties.outputs.version }} | |
changelog: ${{ steps.properties.outputs.changelog }} | |
steps: | |
- name: Maximize Build Space | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
large-packages: false | |
docker-images: false | |
- name: Fetch Sources | |
uses: actions/checkout@v3 | |
- name: Gradle Wrapper Validation | |
uses: gradle/[email protected] | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: zulu | |
java-version: 11 | |
- name: Export Properties | |
id: properties | |
run: | | |
PROPERTIES="$(./gradlew properties --console=plain -q)" | |
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" | |
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" | |
CHANGELOG="${CHANGELOG//'%'/'%25'}" | |
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" | |
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" | |
echo "::set-output name=version::$VERSION" | |
echo "::set-output name=changelog::$CHANGELOG" | |
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier" | |
./gradlew listProductsReleases | |
- name: Run Tests | |
run: ./gradlew test | |
- name: Collect Tests Result | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tests-result | |
path: ${{ github.workspace }}/build/reports/tests | |
- name: Test generated vaults with official CLI tool | |
run: ./gradlew integrationTest | |
- name: Setup Plugin Verifier IDEs Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides | |
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} | |
- name: Run Plugin Verification tasks | |
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }} | |
- name: Collect Plugin Verifier Result | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pluginVerifier-result | |
path: ${{ github.workspace }}/build/reports/pluginVerifier | |
- name: Prepare Plugin Artifact | |
id: artifact | |
shell: bash | |
run: | | |
cd ${{ github.workspace }}/build/distributions | |
FILENAME=`ls *.zip` | |
unzip "$FILENAME" -d content | |
echo "::set-output name=filename::${FILENAME:0:-4}" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.artifact.outputs.filename }} | |
path: ./build/distributions/content/*/* | |
- name: Notify to Telegram | |
uses: yanzay/[email protected] | |
if: always() | |
with: | |
chat: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
status: ${{ job.status }} | |
# Prepare a draft release for GitHub Releases page for the manual verification | |
# If accepted and published, release workflow would be triggered | |
releaseDraft: | |
name: Release Draft | |
if: github.event_name != 'pull_request' | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
# Check out current repository | |
- name: Fetch Sources | |
uses: actions/checkout@v3 | |
# Remove old release drafts by using the curl request for the available releases with draft flag | |
- name: Remove Old Release Drafts | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh api repos/{owner}/{repo}/releases \ | |
--jq '.[] | select(.draft == true) | .id' \ | |
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} | |
# Create new release draft - which is not publicly visible and requires manual acceptance | |
- name: Create Release Draft | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create v${{ needs.build.outputs.version }} \ | |
--draft \ | |
--title "v${{ needs.build.outputs.version }}" \ | |
--notes "$(cat << 'EOM' | |
${{ needs.build.outputs.changelog }} | |
EOM | |
)" |