Skip to content

Publish packages to public repositories #28

Publish packages to public repositories

Publish packages to public repositories #28

name: Publish packages to public repositories
on:
workflow_call:
inputs:
artifactName:
required: true
type: string
description: "The github artifact holding the wheel file which will be published"
do_brew:
required: false
default: true
type: boolean
description: "Publish to brew repository"
do_chocolatey:
required: false
default: true
type: boolean
description: "Publish to Chocolatey repository"
do_snap:
required: false
default: true
type: boolean
description: "Publish to snap repository"
workflow_dispatch:
inputs:
release:
required: true
type: string
description: "The existing github release which will be published (e.g. v0.1.0)"
do_brew:
required: false
default: true
type: boolean
description: "Publish to brew repository"
do_chocolatey:
required: false
default: true
type: boolean
description: "Publish to Chocolatey repository"
do_snap:
required: false
default: true
type: boolean
description: "Publish to snap repository"
jobs:
publish-brew:
runs-on: ubuntu-latest
if: ${{ inputs.do_brew }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
# Download either via release or provided artifact
- name: Download release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: gh release download ${{ inputs.release }} --pattern "*.whl" --dir dist
env:
GH_TOKEN: ${{ github.token }}
- name: Download artifact
if: ${{ github.event_name == 'workflow_call' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifactName }}
path: dist
- name: Set Git user as GitHub actions
run: git config --global user.email "[email protected]" && git config --global user.name "github-actions"
- name: Update homebrew cask
run: scripts/update-brew-cask.sh "dist/algokit*-py3-none-any.whl" "algorandfoundation/homebrew-tap"
env:
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
publish-chocolatey:
runs-on: windows-latest
if: ${{ inputs.do_chocolatey }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
# Download either via release or provided artifact
- name: Download release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: gh release download ${{ inputs.release }} --pattern "*.whl" --dir dist
env:
GH_TOKEN: ${{ github.token }}
- name: Download artifact
if: ${{ github.event_name == 'workflow_call' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifactName }}
path: dist
- name: Update chocolatey files
id: update_chocolatey_files
run: scripts/update-chocolatey-package.ps1
- name: Build package
uses: crazy-max/ghaction-chocolatey@v2
with:
args: pack --version ${{ steps.update_chocolatey_files.outputs.version }} .\scripts\chocolatey\algokit\algokit.nuspec
- name: Set API key
uses: crazy-max/ghaction-chocolatey@v2
with:
args: apikey --api-key ${{ secrets.CHOCOLATEY_API_KEY }} -source https://push.chocolatey.org/
- name: Push package
uses: crazy-max/ghaction-chocolatey@v2
with:
args: push --source https://push.chocolatey.org/
publish-snap:
runs-on: ubuntu-latest
needs: build-snap-binaries

Check failure on line 119 in .github/workflows/publish-release-packages.yaml

View workflow run for this annotation

GitHub Actions / Publish packages to public repositories

Invalid workflow file

The workflow is not valid. .github/workflows/publish-release-packages.yaml (Line: 119, Col: 12): Job 'publish-snap' depends on unknown job 'build-snap-binaries'.
if: ${{ inputs.do_snap }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set release version
shell: bash
continue-on-error: true
run: |
if [ -z "${{ inputs.release }}" ]; then
echo "RELEASE_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
git describe --tags $(git rev-list --tags --max-count=1)
else
echo "RELEASE_VERSION=${{ inputs.release }}" >> $GITHUB_ENV
fi
- name: Configure build environment
if: ${{ github.event_name == 'workflow_dispatch' && inputs.do_snap && inputs.release != '' }}
shell: bash
run: |
artifacts_dir="${{ github.workspace }}${{ runner.os == 'Windows' && '\dist\artifacts' || '/dist/artifacts' }}"
mkdir -p $artifacts_dir
package_name="algokit${{ env.RELEASE_VERSION }}-${{ runner.os }}_${{ runner.arch }}"
echo "PACKAGE_NAME=`echo $package_name | tr '[:upper:]' '[:lower:]'`" >> $GITHUB_ENV
echo "ARTIFACTS_DIR=${artifacts_dir}" >> $GITHUB_ENV
- name: Build linux binary
if: ${{ github.event_name == 'workflow_dispatch' && inputs.do_snap && inputs.release != '' }}
uses: ./.github/actions/build-binaries/linux
with:
package_name: ${{ env.PACKAGE_NAME }}
version: ${{ env.RELEASE_VERSION }}
artifacts_dir: ${{ env.ARTIFACTS_DIR }}
- name: Download binary artifact from release
if: ${{ (env.RELEASE_VERSION != '') || (github.event_name == 'workflow_dispatch' && inputs.release != '') }}
run: |
gh release download ${{ inputs.release }} --pattern "*-linux_x64.tar.gz" --dir dist
echo "BINARY_PATH=$(ls dist/*-linux_x64.tar.gz)" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ github.token }}
- name: Generate snapcraft.yaml
run: |
./scripts/snap/create-snapcraft-yaml.sh ${{ github.workspace }} ${{ env.RELEASE_VERSION }} ${{ env.BINARY_PATH }} "stable"
- name: Build snap
uses: snapcore/action-build@v1
with:
snapcraft-args: --target-arch amd64
- name: Set path to snap binary
shell: bash
run: |
echo "SNAP_BINARY_PATH=$(find ${{ github.workspace }} -name '*.snap')" >> $GITHUB_ENV
- name: Publish snap
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_RELEASE_TOKEN }}
with:
snap: ${{ env.SNAP_BINARY_PATH }}
release: stable