Package workflow (run-x/opta)
The Package workflow from run-x/opta, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Package workflow from the run-x/opta repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Package
on:
workflow_dispatch:
inputs:
version:
description: version tag
required: false
release:
types: [published]
jobs:
package-linux:
# needs: create-destroy-tests
runs-on: ubuntu-18.04
env:
VERSION: ${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install python dependencies
run: |
pip install pipenv
pipenv install --deploy
source $(pipenv --venv)/bin/activate
- name: Package
run: |
if [ -z "$VERSION" ]; then export VERSION=$(echo "$GITHUB_REF" | sed 's|refs/tags/v||'); fi
make build-binary
cd dist/opta
zip -r opta.zip ./*
- name: Upload Linux Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.ALL_GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/opta/opta.zip
asset_name: opta_linux.zip
asset_content_type: application/zip
package-centos:
# needs: create-destroy-tests
runs-on: ubuntu-18.04
env:
VERSION: ${{ github.event.inputs.version }}
container:
image: "centos:centos7"
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
yum install -y unzip make zip centos-release-scl
yum install -y rh-python38
- name: Install python dependencies
run: |
scl enable rh-python38 - << \EOF
pip3.8 install pipenv
pipenv install --deploy --dev
source $(pipenv --venv)/bin/activate
EOF
- name: Package
run: |
scl enable rh-python38 - << \EOF
if [ -z "$VERSION" ]; then export VERSION=$(echo "$GITHUB_REF" | sed 's|refs/tags/v||'); fi
make build-binary
cd dist/opta
zip -r opta.zip ./*
EOF
- name: Upload CentOS Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.ALL_GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/opta/opta.zip
asset_name: opta_centos.zip
asset_content_type: application/zip
package-macos:
# needs: create-destroy-tests
runs-on: macos-10.15
env:
VERSION: ${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install python dependencies
run: |
pip install pipenv
pipenv install --deploy --dev
source $(pipenv --venv)/bin/activate
- name: Package
run: |
if [ -z "$VERSION" ]; then export VERSION=$(echo "$GITHUB_REF" | sed 's|refs/tags/v||'); fi
make build-binary
cd dist/opta
zip -r opta.zip ./*
- name: Upload Mac Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.ALL_GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/opta/opta.zip
asset_name: opta_mac.zip
asset_content_type: application/zip
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Package on: workflow_dispatch: inputs: version: description: version tag required: false release: types: [published] jobs: package-linux: timeout-minutes: 30 # needs: create-destroy-tests runs-on: ubuntu-18.04 env: VERSION: ${{ github.event.inputs.version }} steps: - uses: actions/checkout@v2 - name: Set up Python 3.8 uses: actions/setup-python@v2 with: cache: 'pip' python-version: 3.8 - name: Install python dependencies run: | pip install pipenv pipenv install --deploy source $(pipenv --venv)/bin/activate - name: Package run: | if [ -z "$VERSION" ]; then export VERSION=$(echo "$GITHUB_REF" | sed 's|refs/tags/v||'); fi make build-binary cd dist/opta zip -r opta.zip ./* - name: Upload Linux Release uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.ALL_GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: dist/opta/opta.zip asset_name: opta_linux.zip asset_content_type: application/zip package-centos: timeout-minutes: 30 # needs: create-destroy-tests runs-on: ubuntu-18.04 env: VERSION: ${{ github.event.inputs.version }} container: image: "centos:centos7" steps: - uses: actions/checkout@v2 - name: Install dependencies run: | yum install -y unzip make zip centos-release-scl yum install -y rh-python38 - name: Install python dependencies run: | scl enable rh-python38 - << \EOF pip3.8 install pipenv pipenv install --deploy --dev source $(pipenv --venv)/bin/activate EOF - name: Package run: | scl enable rh-python38 - << \EOF if [ -z "$VERSION" ]; then export VERSION=$(echo "$GITHUB_REF" | sed 's|refs/tags/v||'); fi make build-binary cd dist/opta zip -r opta.zip ./* EOF - name: Upload CentOS Release uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.ALL_GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: dist/opta/opta.zip asset_name: opta_centos.zip asset_content_type: application/zip package-macos: timeout-minutes: 30 # needs: create-destroy-tests runs-on: macos-10.15 env: VERSION: ${{ github.event.inputs.version }} steps: - uses: actions/checkout@v2 - name: Set up Python 3.8 uses: actions/setup-python@v2 with: cache: 'pip' python-version: 3.8 - name: Install python dependencies run: | pip install pipenv pipenv install --deploy --dev source $(pipenv --venv)/bin/activate - name: Package run: | if [ -z "$VERSION" ]; then export VERSION=$(echo "$GITHUB_REF" | sed 's|refs/tags/v||'); fi make build-binary cd dist/opta zip -r opta.zip ./* - name: Upload Mac Release uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.ALL_GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: dist/opta/opta.zip asset_name: opta_mac.zip asset_content_type: application/zip
What changed
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.