Release packages #10
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: Release packages | |
on: | |
release: | |
types: | |
- released | |
permissions: | |
contents: read | |
jobs: | |
update-homebrew: | |
name: Update Homebrew Tap | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Salami repo | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.release.target_commitish }} | |
path: salami | |
- name: Checkout Salami homebrew repo | |
uses: actions/checkout@v3 | |
with: | |
repository: petrgazarov/homebrew-salami | |
path: homebrew_salami | |
token: ${{ secrets.HOMEBREW_SALAMI_GITHUB_TOKEN }} | |
- name: Get Salami version | |
id: salami-version | |
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Generate Homebrew Tap | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
export SALAMI_VERSION="${{ steps.salami-version.outputs.version }}" | |
gh release download --repo petrgazarov/salami "${SALAMI_VERSION}" -p 'salami*darwin*' -p 'salami*linux*' --skip-existing | |
for i in \ | |
"darwin x64 SALAMI_DARWIN_X64" \ | |
"darwin arm64 SALAMI_DARWIN_ARM64" \ | |
"linux x64 SALAMI_LINUX_X64" \ | |
"linux arm64 SALAMI_LINUX_ARM64" \ | |
; do | |
set -- $i | |
OS="$1" | |
ARCH="$2" | |
ENV_VAR="$3" | |
SHA256="$(sha256sum "salami-${SALAMI_VERSION}-${OS}-${ARCH}" | cut -f1 -d' ')" | |
SHA256_VAR="${ENV_VAR}_SHA256" | |
URL_VAR="${ENV_VAR}_URL" | |
export "${SHA256_VAR}=${SHA256}" | |
export "${URL_VAR}=https://github.com/petrgazarov/salami/releases/download/${SALAMI_VERSION}/salami-${SALAMI_VERSION}-${OS}-${ARCH}" | |
done | |
envsubst '$SALAMI_VERSION,$SALAMI_DARWIN_X64_URL,$SALAMI_DARWIN_X64_SHA256,$SALAMI_DARWIN_ARM64_URL,$SALAMI_DARWIN_ARM64_SHA256,$SALAMI_LINUX_X64_URL,$SALAMI_LINUX_X64_SHA256,$SALAMI_LINUX_ARM64_URL,$SALAMI_LINUX_ARM64_SHA256' < "./salami/.github/templates/salami_tap_template.rb" > ./homebrew_salami/salami.rb | |
- name: Commit and push updated formula | |
working-directory: homebrew_salami | |
run: | | |
set -euo pipefail | |
git config user.name petrgazarov | |
git config user.email [email protected] | |
git add salami.rb | |
echo "::group::git diff" | |
git --no-pager diff | |
echo "::endgroup::" | |
git commit -m "Brew formula update for Salami version ${{ steps.salami-version.outputs.version }}" | |
git push origin HEAD:main | |
update-chocolatey: | |
name: Update Chocolatey Package | |
runs-on: windows-latest | |
steps: | |
- name: Get Salami version | |
id: salami-version | |
shell: bash | |
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Checkout Salami repo | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.release.target_commitish }} | |
path: salami | |
- name: Checkout Salami chocolatey repo | |
uses: actions/checkout@v3 | |
with: | |
repository: petrgazarov/salami-chocolatey | |
path: salami_chocolatey | |
token: ${{ secrets.CHOCOLATEY_SALAMI_GITHUB_TOKEN }} | |
- name: Update version in Chocolatey repo | |
working-directory: salami_chocolatey | |
shell: bash | |
run: | | |
set -euo pipefail | |
NEW_VERSION="${{ steps.salami-version.outputs.version }}" | |
sed -i "s|https://github.com/petrgazarov/salami/releases/download/.*/salami-.*-windows-x64|https://github.com/petrgazarov/salami/releases/download/${NEW_VERSION}/salami-${NEW_VERSION}-windows-x64|g" tools/chocolateyInstall.ps1 | |
sed -i "s|<version>.*</version>|<version>${NEW_VERSION}</version>|g" salami.nuspec | |
- name: Commit and push to Salami chocolatey repo | |
working-directory: salami_chocolatey | |
shell: bash | |
run: | | |
set -euo pipefail | |
git config user.name petrgazarov | |
git config user.email [email protected] | |
git add tools salami.nuspec | |
echo "::group::git diff" | |
git --no-pager diff | |
echo "::endgroup::" | |
if ! git diff --exit-code; then | |
git commit -m "Update version to ${{ steps.salami-version.outputs.version }}" | |
git tag -a "${{ steps.salami-version.outputs.version }}" -m "Chocolatey package update for Salami version ${{ steps.salami-version.outputs.version }}" | |
git push origin "${{ steps.salami-version.outputs.version }}" | |
fi | |
- name: Publish Salami chocolatey package | |
working-directory: salami_chocolatey | |
shell: bash | |
run: | | |
set -euo pipefail | |
choco config set --name=defaultPushSource --value=https://push.chocolatey.org/ | |
choco pack | |
choco push salami.${{ steps.salami-version.outputs.version }}.nupkg -k ${{ secrets.CHOCOLATEY_API_KEY }} |