Skip to content

v1.0.6

v1.0.6 #19

name: Publish Latest Firmware to S3
permissions:
id-token: write
contents: read
on:
workflow_dispatch:
inputs:
asset_name:
description: "Name of the asset to upload (e.g. esp-miner.bin)"
required: true
default: esp-miner.bin
release:
types: [published]
jobs:
upload:
runs-on: ubuntu-latest
env:
REPO: Advanced-Crypto-Services/acs-esp-miner
S3_BUCKET: ${{ secrets.S3_BUCKET }}
AWS_REGION: ${{ secrets.AWS_REGION }}
ROLE_ARN: arn:aws:iam::603187095057:role/GitHubActionsFirmwareUploadRole
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: Determine asset name
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "ASSET_NAME=${{ github.event.inputs.asset_name }}" >> $GITHUB_ENV
else
# For release events, default to esp-miner.bin
echo "ASSET_NAME=esp-miner.bin" >> $GITHUB_ENV
fi
- name: Print asset name (debug)
run: |
echo "Using asset: $ASSET_NAME"
- name: Download release asset
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
# Get the latest release tag from GitHub API
LATEST_TAG=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | jq -r '.tag_name')
echo "Latest release tag: $LATEST_TAG"
URL="https://github.com/${REPO}/releases/download/$LATEST_TAG/$ASSET_NAME"
else
URL="https://github.com/${REPO}/releases/download/${{ github.event.release.tag_name }}/$ASSET_NAME"
fi
echo "Downloading $URL"
curl -L -o "$ASSET_NAME" "$URL"
- name: Upload to S3
run: |
aws s3 cp "$ASSET_NAME" \
s3://$S3_BUCKET/firmware/acs-esp-miner/latest/"$ASSET_NAME" \
--acl public-read --region $AWS_REGION