Skip to content

Publish Release

Publish Release #2

Workflow file for this run

name: Publish Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag for the release'
required: true
title:
description: 'Title of the release'
required: true
description:
description: 'Path to the markdown file for release description'
default: 'release_descriptions/?.md'
required: true
permissions:
contents: write # Ensures the GITHUB_TOKEN can create releases
jobs:
create-github-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Read Release Description from Markdown File
run: |
if [ -f "${{ github.event.inputs.description }}" ]; then
description=$(<"${{ github.event.inputs.description }}")
else
description="No description provided."
fi
echo "DESCRIPTION<<EOF" >> $GITHUB_ENV
echo "$description" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DESCRIPTION: ${{ env.DESCRIPTION }}
run: |
tag="${{ github.event.inputs.tag }}"
title="${{ github.event.inputs.title }}"
description="$DESCRIPTION"
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg tag "$tag" --arg title "$title" --arg description "$description" \
'{tag_name: $tag, target_commitish: "main", name: $title, body: $description, draft: false, prerelease: false}')" \
https://api.github.com/repos/JEMcats-Software/WebGlass/releases
upload-to-s3:
runs-on: ubuntu-latest
needs: create-github-release # Ensure this runs after the release is created
steps:
- name: Checkout main branch
uses: actions/checkout@v3
with:
ref: main # Checkout the 'main' branch
# Install AWS CLI
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv3.zip"
unzip awscliv3.zip
sudo ./aws/install --update
aws --version # Verify installation
# Configure AWS credentials
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
# Minify JavaScript
- name: Minify JavaScript
run: |
npm install -g terser
terser WebGlass.js -o WebGlass.min.js --compress --mangle
# Sync contents to S3 bucket while excluding .github folder
- name: Sync to S3
run: |
aws s3 cp WebGlass.js s3://cdn.jemcats.software/WebGlass/${{ github.event.inputs.tag }}/WebGlass.js
aws s3 cp WebGlass.min.js s3://cdn.jemcats.software/WebGlass/${{ github.event.inputs.tag }}/WebGlass.min.js
aws s3 cp demo/ s3://jemcats.software/github_pages/WebGlass/ --recursive
- name: Clear and Publish Latest to S3
run: |
aws s3 rm s3://cdn.jemcats.software/WebGlass/latest/ --recursive
aws s3 cp s3://cdn.jemcats.software/WebGlass/${{ github.event.inputs.tag }}/ s3://cdn.jemcats.software/WebGlass/latest/ --recursive