Skip to content
Latchkey

Attach Assets workflow (davidrapan/ha-solarman)

The Attach Assets workflow from davidrapan/ha-solarman, explained and optimized by Latchkey.

B

CI health: B - good

Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: davidrapan/ha-solarman.github/workflows/assets.yamlLicense MITView source

What it does

This is the Attach Assets workflow from the davidrapan/ha-solarman repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Attach Assets
on:
  release:
    types:
      - created
jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: true
    - name: Set
      run: |
          echo "workspace=${{ github.workspace }}" >> $GITHUB_ENV
          echo "name=$(echo ${{ github.event.repository.name }} | sed 's/^[^-]*-//')" >> $GITHUB_ENV
          echo "version=$(echo '${{ github.event.release.name }}' | cut -c 2-)" >> $GITHUB_ENV
    - name: Prepare
      run: |
          cp $workspace/license $workspace/custom_components/$name/
          sed -i "s/0\.0\.0/$version/g" $workspace/custom_components/$name/manifest.json
    - name: Zip
      run: |
          cd $workspace/custom_components/$name
          zip -r ../$name.zip . -x "*.git*" "*.git/*" "*.github/*"
    - name: Release
      uses: softprops/action-gh-release@v1
      if: startsWith(github.ref, 'refs/tags/')
      with:
        files: ${{ env.workspace }}/custom_components/${{ env.name }}.zip

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Attach Assets
on:
  release:
    types:
      - created
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    permissions:
      contents: write
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: true
    - name: Set
      run: |
          echo "workspace=${{ github.workspace }}" >> $GITHUB_ENV
          echo "name=$(echo ${{ github.event.repository.name }} | sed 's/^[^-]*-//')" >> $GITHUB_ENV
          echo "version=$(echo '${{ github.event.release.name }}' | cut -c 2-)" >> $GITHUB_ENV
    - name: Prepare
      run: |
          cp $workspace/license $workspace/custom_components/$name/
          sed -i "s/0\.0\.0/$version/g" $workspace/custom_components/$name/manifest.json
    - name: Zip
      run: |
          cd $workspace/custom_components/$name
          zip -r ../$name.zip . -x "*.git*" "*.git/*" "*.github/*"
    - name: Release
      uses: softprops/action-gh-release@v1
      if: startsWith(github.ref, 'refs/tags/')
      with:
        files: ${{ env.workspace }}/custom_components/${{ env.name }}.zip
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow