Publish packages to public repositories #32
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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: 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 |