Skip to content

Draft Release

Draft Release #311

Workflow file for this run

name: Draft Release
on:
workflow_dispatch:
push:
branches: [ main ]
jobs:
buildRustLibrary:
name: Create Rust Library Artifact
runs-on: ubuntu-latest
container:
image: rust:1.81-alpine3.20
steps:
- name: Fetch Sources
uses: actions/checkout@v4
- name: Install Zig
shell: sh
env:
SDKROOT: ${{ github.workspace }}/jrad/macos-sdk-11.3
run: |
cd jrad
apk update && apk add --no-cache git musl-dev xz asciidoctor zig
xz -d -c macos-sdk-11.3.tar.xz | tar -x
rustup target add \
x86_64-unknown-linux-gnu \
aarch64-unknown-linux-gnu \
x86_64-apple-darwin \
aarch64-apple-darwin
cargo install [email protected]
cargo zigbuild --locked --release \
--target=x86_64-apple-darwin \
--target=aarch64-apple-darwin \
--target=x86_64-unknown-linux-gnu \
--target=aarch64-unknown-linux-gnu
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cdylib
path: |
target/aarch64-unknown-linux-gnu/release/libjrad.so
target/aarch64-unknown-linux-gnu/release/jrad
target/aarch64-apple-darwin/release/libjrad.dylib
target/x86_64-apple-darwin/release/libjrad.dylib
target/x86_64-unknown-linux-gnu/release/libjrad.so
target/x86_64-unknown-linux-gnu/release/jrad
buildPluginArtifact:
name: Create Plugin Artifact
runs-on: ubuntu-latest
needs: buildRustLibrary
outputs:
version: ${{ steps.properties.outputs.version }}
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v4
# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v4
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
cache: gradle
# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Install Radicle
env:
RAD_HOME: ${{ github.workspace }}/.radicle
run: |
curl -sSf https://radicle.xyz/install | sh
echo "${RAD_HOME}/bin" >> $GITHUB_PATH
echo "RAD_HOME=${{ github.workspace }}/.radicle" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: cdylib
# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
id: artifact
shell: bash
run: |
# on linux there's a bug that causes buildPlugin to fail the first time: https://youtrack.jetbrains.com/issue/IDEA-291977
./gradlew buildPlugin || ./gradlew buildPlugin
cd ${{ github.workspace }}/build/distributions
FILENAME=`ls *.zip`
unzip "$FILENAME" -d content
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/content/*/*
# 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: buildPluginArtifact
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v4
# 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.buildPluginArtifact.outputs.version }} \
--draft \
--title "v${{ needs.buildPluginArtifact.outputs.version }}" \
--generate-notes