2020-12-06 17:16:17 +00:00
|
|
|
# Workflow For Releases
|
|
|
|
#
|
|
|
|
# Automatically creates and uploads a complete release archive for the given
|
|
|
|
# release.
|
|
|
|
name: Release Workflow
|
|
|
|
|
|
|
|
# Is triggered when a new release is published or by hand
|
|
|
|
# If triggered by hand, the release tag that this should target has to be
|
|
|
|
# specified.
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [published]
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
tag:
|
|
|
|
description: 'Release Tag'
|
|
|
|
required: true
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
upload:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Get Version
|
|
|
|
if: ${{ github.event.inputs.tag }} != ''
|
|
|
|
run: |
|
|
|
|
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
|
|
|
|
echo "Manual Release Triggered"
|
|
|
|
RELEASE_TAG=${{ github.event.inputs.tag }}
|
|
|
|
else
|
|
|
|
echo "Automatic Release Triggered"
|
|
|
|
RELEASE_TAG=${GITHUB_REF#refs/tags/}
|
|
|
|
fi
|
|
|
|
echo "Publishing Version $RELEASE_TAG"
|
2023-02-13 20:51:18 +00:00
|
|
|
{
|
|
|
|
echo "RELEASE_TAG=$RELEASE_TAG"
|
|
|
|
echo "POLYBAR_DIR=polybar-$RELEASE_TAG"
|
|
|
|
echo "POLYBAR_ARCHIVE=polybar-$RELEASE_TAG.tar.gz"
|
|
|
|
} >> "$GITHUB_ENV"
|
2020-12-06 17:16:17 +00:00
|
|
|
|
|
|
|
# Checks out the target tag
|
2024-08-04 11:36:52 +00:00
|
|
|
- uses: actions/checkout@v4
|
2020-12-06 17:16:17 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ env.RELEASE_TAG }}
|
|
|
|
submodules: true
|
|
|
|
path: ${{ env.POLYBAR_DIR }}
|
|
|
|
|
|
|
|
- name: Create Release Archive
|
|
|
|
run: |
|
|
|
|
find "$DIR" -type d -name ".git" -exec rm -rf {} \+
|
|
|
|
tar czf "$ARCHIVE" "$DIR"
|
|
|
|
echo "SHA256SUM=$(sha256sum "$ARCHIVE" | cut -d ' ' -f 1)" >> "$GITHUB_ENV"
|
|
|
|
env:
|
|
|
|
DIR: ${{ env.POLYBAR_DIR }}
|
|
|
|
ARCHIVE: ${{ env.POLYBAR_ARCHIVE }}
|
|
|
|
|
|
|
|
- name: Get Upload URL
|
|
|
|
id: get_upload_url
|
2024-08-04 11:36:52 +00:00
|
|
|
uses: actions/github-script@v7
|
2020-12-06 17:16:17 +00:00
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
const tag = '${{ env.RELEASE_TAG }}';
|
|
|
|
console.log(`Getting Upload URL for '${tag}'`);
|
|
|
|
const release = await github.repos.getReleaseByTag({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
tag: tag
|
|
|
|
});
|
|
|
|
core.exportVariable('UPLOAD_URL', release.data.upload_url);
|
|
|
|
core.exportVariable('RELEASE_ID', release.data.id);
|
|
|
|
core.exportVariable('RELEASE_BODY', release.data.body);
|
|
|
|
|
|
|
|
- name: Upload Release Archive
|
|
|
|
id: upload_archive
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ env.UPLOAD_URL }}
|
|
|
|
asset_path: "./${{ env.POLYBAR_ARCHIVE }}"
|
|
|
|
asset_name: ${{ env.POLYBAR_ARCHIVE }}
|
|
|
|
asset_content_type: application/gzip
|
|
|
|
|
|
|
|
# Adds a download section to the beginning of the release body
|
|
|
|
- name: Update Release Body
|
2024-08-04 11:36:52 +00:00
|
|
|
uses: actions/github-script@v7
|
2020-12-06 17:16:17 +00:00
|
|
|
env:
|
|
|
|
# Existing release body, fetched in the get_upload_url step.
|
|
|
|
RELEASE_BODY: ${{ env.RELEASE_BODY }}
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
const fname = '${{ env.POLYBAR_ARCHIVE }}'
|
|
|
|
const url = '${{ steps.upload_archive.outputs.browser_download_url }}'
|
|
|
|
const hash = '${{ env.SHA256SUM }}'
|
2023-11-05 19:01:55 +00:00
|
|
|
let body = "## Download\n\n"
|
2020-12-06 17:16:17 +00:00
|
|
|
body += `[${fname}](${url}) (**sha256**: \`${hash}\`)\n\n`
|
|
|
|
body += process.env.RELEASE_BODY;
|
|
|
|
|
|
|
|
const release = await github.repos.updateRelease({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
release_id: '${{ env.RELEASE_ID}}',
|
|
|
|
body: body
|
|
|
|
});
|