ci: Automatically run release pipeline when github draft release is r… #12
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: Pre-Release | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build_release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
name: linux | |
- os: macos-14 | |
name: macos | |
- os: windows-2019 | |
name: windows | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 21 | |
- name: Append build settings to .bazelrc | |
shell: bash | |
run: | | |
TAG=${{ github.ref_name }} | |
echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}" >> .bazelrc | |
echo "build --config=ci" >> .bazelrc | |
echo "build --//deploy:jazzer_version=${TAG#v}" >> .bazelrc | |
- name: Build | |
shell: bash | |
# Double forward slashes are converted to single ones by Git Bash on Windows, so we use working directory | |
# relative labels instead. | |
run: | | |
bazelisk build ${{env.BUILD_BUDDY_CONFIG}} deploy:jazzer :jazzer_release | |
cp -L $(bazel cquery --output=files deploy:jazzer) jazzer-${{ matrix.name }}.jar | |
cp -L $(bazel cquery --output=files :jazzer_release) jazzer-${{ matrix.name }}.tar.gz | |
- name: Upload jazzer.jar | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jazzer_tmp_${{ matrix.name }} | |
path: jazzer-${{ matrix.name }}.jar | |
if-no-files-found: error | |
- name: Upload release archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jazzer_releases_${{ matrix.name }} | |
path: jazzer-${{ matrix.name }}.tar.gz | |
if-no-files-found: error | |
merge_jars: | |
runs-on: ubuntu-22.04 | |
needs: build_release | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download individual jars | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: jazzer_tmp_* | |
merge-multiple: true | |
path: _tmp/ | |
- name: Merge jars | |
run: | | |
bazel run @rules_jvm_external//private/tools/java/com/github/bazelbuild/rules_jvm_external/jar:MergeJars -- \ | |
--output "$(pwd)"/_tmp/jazzer.jar \ | |
$(find "$(pwd)/_tmp/" -name '*.jar' -printf "--sources %h/%f ") | |
- name: Upload merged jar | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jazzer | |
path: _tmp/jazzer.jar | |
if-no-files-found: error | |
maven_predeploy: | |
runs-on: ubuntu-22.04 | |
needs: merge_jars | |
environment: | |
name: Deploy | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 8 | |
- name: Append build settings to .bazelrc | |
shell: bash | |
run: | | |
TAG=${{ github.ref_name }} | |
echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}" >> .bazelrc | |
echo "build --config=ci" >> .bazelrc | |
echo "build --//deploy:jazzer_version=${TAG#v}" >> .bazelrc | |
- name: Download merged jar | |
uses: actions/download-artifact@v4 | |
with: | |
name: jazzer | |
path: _tmp/ | |
- name: Run Deployment | |
env: | |
RELEASE_SIGNING_KEY_ID: ${{ secrets.RELEASE_SIGNING_KEY_ID }} | |
RELEASE_SIGNING_KEY_PRIVATE: ${{ secrets.RELEASE_SIGNING_KEY_PRIVATE }} | |
MAVEN_USER: ${{ secrets.MAVEN_USER }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
run: JAZZER_JAR_PATH="$(pwd)/_tmp/jazzer.jar" bazel run deploy | |
create_release: | |
needs: build_release | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write # for creating releases | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Download individual tar.gzs | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: jazzer_releases_* | |
merge-multiple: true | |
path: _releases/ | |
- name: create release | |
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9 | |
with: | |
generate_release_notes: true | |
draft: true | |
files: | | |
_releases/jazzer-linux.tar.gz | |
_releases/jazzer-macos.tar.gz | |
_releases/jazzer-windows.tar.gz |