Skip to content

Commit

Permalink
Avoid double-building, and update README.
Browse files Browse the repository at this point in the history
If you moved towards using my `github-action-build` you'd use the
same script - so it would get invoked twice:

* Once by the build step
* Once by the upload step

Depreciate the build-step, but let it work for legacy for now.
  • Loading branch information
skx committed Sep 14, 2019
1 parent 153a0bf commit 54e5edf
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 12 deletions.
61 changes: 52 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,67 @@
# GitHub Action for Uploading Release Artifacts

This repository contains a simple GitHub Action implementation, which allows you to attach binaries to a new release.
This repository contains a simple GitHub Action implementation, which allows you to attach binaries to a new (github) release of your repository.


## Enabling the action

There are two steps required to use this action:

* Enable the action inside your repository.
* This will mean creating a file `.github/workflows/release.yml` which is where the action is invoked, specifying a pattern to describe which binary-artifacts are uploaded.
* Add your project-specific `.github/build` script.
* This is the script which will generate the files this action will upload.
* A C-project might just run `make`.
* A golang-based project might run `go build .` multiple times for different architectures.
* This will mean creating a file `.github/workflows/release.yml` which is where the action is invoked.
* You'll specify a pattern to describe which binary-artifacts are uploaded.
* Ensure your binary artifacts are generated.
* Ideally you should do this in your workflow using another action.
* But if you're in a hurry you can add a project-specific `.github/build` script.

## Sample Configuration: Preferred

## Sample Configuration
The following configuration file uses this action, along with another to build a project.

This configuration uploads any file in your repository which matches the
shell-pattern `puppet-summary-*`, and is defined in the file `.github/workflows/release.yml`:
This is the preferred approach:

```
on: release
name: Handle Release
jobs:
generate:
name: Create release-artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Generate artifacts
uses: skx/github-action-build@master
- name: Upload artifacts
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'example-*'
```

This is the preferred approach because it uses a pair of distinct actions,
each having one job:

* [skx/github-action-build](https://github.com/skx/github-action-build/)
* Generates the build artifacts.
* i.e. Compiles your binaries.
* [skx/github-action-publis-binaries](https://github.com/skx/github-action-publis-binaries)
* Uploads the previously-generated the build artifacts.


## Sample Configuration: Legacy

In the past this action performed __both__ steps:

* Generated the artifacts
* Uploaded the artifacts

That is still possible, but will be removed when actions come out of beta.

For the moment you can continue to work as you did before, add the script `.github/build` to your repository, and configure this action with a pattern of files to upload.

For example the following usage, defined in `.github/workflows/release.yml`, uploads files matching the pattern `puppet-summary-*`.

```
on: release
Expand Down
23 changes: 20 additions & 3 deletions upload-script
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,27 @@ if [ "$IS_DRAFT" = true ]; then
exit 0
fi

# Run the build-script
# Is there a build-script in the repository?
if [ -e .github/build ]; then
chmod 755 .github/build
./.github/build

# Have we found any artifacts?
found=
for file in $*; do
if [ -e "$file" ]; then
found=1
fi
done

# OK if we have no artifacts already present, so we should
# invoke the build-script, which we have confirmed exists.
if [ -z "${found}" ]; then
echo "Artifacts are missing, but build-script is present."
echo "Building.."
chmod 755 .github/build
./.github/build
else
echo "Artifacts are already present, so not running the build-step"
fi
fi

# Prepare the headers
Expand Down

0 comments on commit 54e5edf

Please sign in to comment.