build: bump actions to latest versions (#172) #54
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: Stage | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - ".github/**" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| name: Build plugin | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| - name: Install Java 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: 17 | |
| distribution: 'oracle' | |
| cache: 'gradle' | |
| - name: Build plugin with Gradle | |
| uses: gradle/gradle-build-action@v2 | |
| with: | |
| arguments: | | |
| buildPlugin | |
| -Pgpr.username=${{ github.actor }} | |
| -Pgpr.token=${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload distribution archive as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: distributions | |
| path: ./build/distributions | |
| release: | |
| runs-on: ubuntu-latest | |
| name: Create an early-access release | |
| environment: staging | |
| needs: build | |
| if: github.repository == 'redhat-developer/intellij-dependency-analytics' | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| - name: Download distribution artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: distributions | |
| path: ./distributions | |
| - name: Check for existing early-access release | |
| id: existing_release | |
| uses: actions/github-script@v7 | |
| continue-on-error: true | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const repo_name = context.payload.repository.full_name | |
| var response = await github.request('GET /repos/' + repo_name + '/releases/tags/early-access') | |
| // if the request fails (ie 404) the next steps will not occur and the output will not be set | |
| core.setOutput('id', response.data.id) | |
| - name: Delete early-access release if exists | |
| if: ${{ steps.existing_release.outputs.id }} | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const repo_name = context.payload.repository.full_name | |
| await github.request('DELETE /repos/' + repo_name + '/releases/' + ${{ steps.existing_release.outputs.id }}) | |
| - name: Delete early-access tag if exists | |
| continue-on-error: true | |
| run: git push --delete origin early-access | |
| # a little pause between deleting the release and creating a new one | |
| # without it, the new release might be a weird release, i.e. a draft release | |
| - name: Sleep 5 | |
| run: sleep 5 | |
| - name: Create new early-access release | |
| id: new_release | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const repo_name = context.payload.repository.full_name | |
| const response = await github.request('POST /repos/' + repo_name + '/releases', { | |
| tag_name: 'early-access', | |
| name: 'Early-Access', | |
| draft: false, | |
| prerelease: true, | |
| generate_release_notes: true, | |
| make_latest: 'false' | |
| }) | |
| core.setOutput('upload_url', response.data.upload_url) | |
| - name: Create SHA256 checksums for the binaries | |
| working-directory: distributions | |
| run: | | |
| for pkg in * | |
| do | |
| sha256sum "$pkg" > "$pkg.sha256" | |
| done | |
| - name: Upload packages and checksums as early-access release assets | |
| working-directory: distributions | |
| run: | | |
| for file in * | |
| do | |
| asset_name=$(basename "$file") | |
| upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g") | |
| curl --data-binary @"$file" \ | |
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Content-Type: application/octet-stream" \ | |
| "$upload_url" | |
| done |