-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ce0888
commit 52ef37b
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: release | ||
|
||
on: | ||
schedule: | ||
- cron: '0,15,30,45 * * * *' # schedule nightly build daily at midnight UTC | ||
push: | ||
tags: | ||
- "v*.*.*" # normal release | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Ensure workspace ownership | ||
run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Prepare release body | ||
run: | | ||
if [[ ${{ github.ref }} =~ ^refs/tags/v(.*) ]]; then | ||
RELEASE_TAG=v${BASH_REMATCH[1]} | ||
PRERELEASE=false | ||
else | ||
RELEASE_TAG=nightly | ||
PRERELEASE=true | ||
fi | ||
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV | ||
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV | ||
RELEASE_DATETIME=$(date --rfc-3339=seconds) | ||
cat <<EOF > release_template.md | ||
Release $RELEASE_TAG created from $GITHUB_SHA at $RELEASE_DATETIME | ||
EOF | ||
envsubst < release_template.md > release_body.md | ||
- name: Build source tarball | ||
run: git archive --format=tar HEAD | gzip > archive.tgz | ||
|
||
- name: Remove existing mutalbe tag "nightly" | ||
# https://github.com/softprops/action-gh-release/issues/171 | ||
run: git push origin :refs/tags/nightly || true | ||
# https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution | ||
if: ${{ env.RELEASE_TAG }} == "nightly" | ||
|
||
- name: Create or overwrite a releae | ||
# https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
token: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable | ||
prerelease: ${{ env.PRE_RELEASE }} | ||
tag_name: ${{ env.RELEASE_TAG }} | ||
# The body field does not support environment variable substitution directly. | ||
body_path: release_body.md | ||
files: | | ||
*.tgz |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
types: [ opened, synchronize, reopened, edited ] | ||
|
||
jobs: | ||
tests: | ||
name: tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Ensure workspace ownership | ||
run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v3 |