Skip to content

Commit

Permalink
Add optional git ref input to build workflow, add GH release to relea…
Browse files Browse the repository at this point in the history
…se workflow
  • Loading branch information
briandefiant committed Aug 16, 2023
1 parent 71924cf commit 33e7fc9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
# Allows running the workflow manually
workflow_dispatch:
inputs:
git_ref:
type: string
description: Git ref to build code from
required: true
default: main

jobs:
linux_standalone_build:
Expand All @@ -20,6 +25,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.git_ref }}
# Set up QEMU to support additional platforms
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -55,15 +62,17 @@ jobs:
name: wordfence_cli_${{ matrix.arch }}
path: |
${{ github.workspace }}/docker/build/volumes/output/wordfence_*.tar.gz
${{ github.workspace }}/docker/build/volumes/output/wordfence_*.tar.gz.asc
${{ github.workspace }}/docker/build/volumes/output/wordfence_*.tar.gz.sha256
${{ github.workspace }}/docker/build/volumes/output/wordfence_*.tar.gz.asc
${{ github.workspace }}/docker/build/volumes/output/wordfence_*.tar.gz.sha256.asc
python_build:
name: Python build
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.git_ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
type: boolean
description: Whether to draft a GitHub release
default: true
release_tag:
type: string
description: The tag to create a release for (e.g., v1.0.0); will be created if it doesn't exist
required: true

jobs:
pypi_release:
Expand Down Expand Up @@ -56,3 +60,43 @@ jobs:
--non-interactive \
wordfence_cli_python/*.whl \
wordfence_cli_python/*.tar.gz
github_release:
if: ${{ inputs.release_github }}
name: GitHub release
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
workflow: build.yml
run_number: ${{ inputs.build_run_number }}
- name: Get commit hash from build
id: get-commit-hash
run: |
printf "Getting commit hash for build number %s\\n" "$BUILD_RUN_NUMBER"
BUILD_COMMIT_HASH=$(
gh run list \
--workflow build.yml \
--json headBranch,headSha,number | jq -r '.[] | select(.number=="$BUILD_RUN_NUMBER") | .headSha'
)
echo "BUILD_COMMIT_HASH=${BUILD_COMMIT_HASH}" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_RUN_NUMBER: ${{ inputs.build_run_number }}
- name: Create draft release
uses: softprops/action-gh-release@v1
with:
files: |
wordfence_cli_python/*.tar.gz \
wordfence_cli_python/*.whl \
wordfence_cli_python/*.sha256 \
wordfence_cli_python/*.asc \
wordfence_cli_amd64/*.tar.gz \
wordfence_cli_amd64/*.sha256 \
wordfence_cli_amd64/*.asc \
wordfence_cli_arm64/*.tar.gz \
wordfence_cli_arm64/*.sha256 \
wordfence_cli_arm64/*.asc \
target_commitish: steps.get-commit-hash.outputs.BUILD_COMMIT_HASH
tag_name: inputs.release_tag
draft: true

0 comments on commit 33e7fc9

Please sign in to comment.