-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add early-access build pipeline for main branch #398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| --- | ||
| name: Stage | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - ".github/**" | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| name: Build project | ||
| concurrency: | ||
| group: stage-build-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Java 21 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 21 | ||
| cache: maven | ||
|
|
||
| - name: Build with Maven | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: mvn package -B -DskipTests -Dskip.junit_platform=true | ||
|
|
||
| - name: Upload JAR artifacts | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: distributions | ||
| path: | | ||
| ./target/trustify-da-java-client-*.jar | ||
| !./target/original-*.jar | ||
|
|
||
| release: | ||
| runs-on: ubuntu-latest | ||
| name: Create an early-access release | ||
| concurrency: | ||
| group: stage-release-${{ github.ref }} | ||
| cancel-in-progress: false | ||
| permissions: | ||
| contents: write | ||
| needs: build | ||
| if: github.repository_owner == 'guacsec' | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - 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 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const repo_name = context.payload.repository.full_name | ||
| try { | ||
| const response = await github.request('GET /repos/' + repo_name + '/releases/tags/early-access') | ||
| core.setOutput('id', response.data.id) | ||
| } catch (error) { | ||
| if (error.status === 404) { | ||
| core.info('No existing early-access release found') | ||
| core.setOutput('id', '') | ||
| } else { | ||
| core.setFailed(`Failed to check for early-access release: ${error.status} ${error.message}`) | ||
| } | ||
| } | ||
|
|
||
| - 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: | | ||
| short_sha="${{ github.sha }}" | ||
| short_sha="${short_sha:0:7}" | ||
| # Rename JAR files to include short commit ID and create checksums | ||
| for pkg in *.jar; do | ||
| [ ! -f "$pkg" ] && continue | ||
| new_filename="${pkg%.jar}-${short_sha}.jar" | ||
| echo "Renaming $pkg to $new_filename" | ||
| mv "$pkg" "$new_filename" | ||
| echo "Creating checksum for $new_filename" | ||
| sha256sum "$new_filename" > "$new_filename.sha256" | ||
| done | ||
|
|
||
| - name: Upload packages and checksums as early-access release assets | ||
| working-directory: distributions | ||
| run: | | ||
| set -euo pipefail | ||
| 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") | ||
| echo "Uploading $asset_name..." | ||
| curl --fail-with-body --retry 3 --retry-all-errors --show-error --silent \ | ||
| --data-binary @"$file" \ | ||
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
| -H "Content-Type: application/octet-stream" \ | ||
| "$upload_url" | ||
| echo "" | ||
| done | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.