Publish packages to public repositories #51
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" | |
release_version: | |
required: true | |
type: string | |
description: "The release version that will be published (e.g. 0.1.0)" | |
do_brew: | |
required: false | |
default: true | |
type: boolean | |
description: "Publish to brew repository" | |
do_snap: | |
required: false | |
default: true | |
type: boolean | |
description: "Publish to snap repository" | |
do_winget: | |
required: false | |
default: true | |
type: boolean | |
description: "Publish to Winget repository" | |
workflow_dispatch: | |
inputs: | |
artifactName: | |
required: true | |
type: string | |
description: "The github artifact holding the wheel file which will be published" | |
release_version: | |
required: true | |
type: string | |
description: "The release version that will be published (e.g. 0.1.0)" | |
do_brew: | |
required: false | |
default: true | |
type: boolean | |
description: "Publish to brew repository" | |
do_snap: | |
required: false | |
default: true | |
type: boolean | |
description: "Publish to snap repository" | |
do_winget: | |
required: false | |
default: true | |
type: boolean | |
description: "Publish to Winget repository" | |
jobs: | |
publish-brew: | |
runs-on: ubuntu-latest | |
if: ${{ inputs.do_brew }} | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.BOT_ID }} | |
private-key: ${{ secrets.BOT_SK }} | |
repositories: homebrew-tap | |
owner: algorandfoundation | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Download wheel from release | |
run: gh release download v${{ inputs.release_version }} --pattern "*.whl" --dir dist | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Download binary artifact from release | |
run: gh release download v${{ inputs.release_version }} --pattern "*-brew.tar.gz" --dir dist | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- 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" "dist/algokit*-macos_arm64-brew.tar.gz" "dist/algokit*-macos_x64-brew.tar.gz" "algorandfoundation/homebrew-tap" | |
env: | |
TAP_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
publish-winget: | |
runs-on: windows-latest | |
if: ${{ inputs.do_winget }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Publish to winget | |
shell: pwsh | |
env: | |
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} | |
run: | | |
echo 'Publishing to winget' | |
& .\scripts\winget\update-package.ps1 ` | |
-releaseVersion '${{ inputs.release_version }}' | |
publish-snap: | |
runs-on: ubuntu-latest | |
if: ${{ inputs.do_snap }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Download binary artifact from release | |
run: | | |
gh release download v${{ inputs.release_version }} --pattern "*-snap.tar.gz" --dir dist | |
BINARY_PATH=$(ls dist/*-snap.tar.gz) | |
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Generate snapcraft.yaml | |
run: | | |
./scripts/snap/create-snapcraft-yaml.sh ${{ github.workspace }} ${{ inputs.release_version }} ${{ env.BINARY_PATH }} "stable" | |
- name: Upload snapcraft.yaml as reference artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: snapcraft-yaml | |
path: ${{ github.workspace }}/snap/snapcraft.yaml | |
- 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 |