⬆️ Updated Manager version #57
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: Update Release | |
on: | |
push: | |
paths: | |
- "VERSION" | |
branches: | |
- main | |
jobs: | |
update-formula: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set ENVs | |
run: | | |
VERSION=$(cat VERSION) | |
echo "VERSION"=${VERSION} >> $GITHUB_ENV | |
echo "FORMULA_VERSION=$(echo ${VERSION} | sed 's|v||g')" >> $GITHUB_ENV | |
echo "FILE_NAME=setops-cli_${VERSION}_darwin_amd64.bz2" >> $GITHUB_ENV | |
echo "FORMULA_EXECUTABLE_NAME=setops-cli_${VERSION}_darwin_amd64" >> $GITHUB_ENV | |
- name: Get asset url | |
run: | | |
RELEASE_DATA=$(curl \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/setopsco/releases/releases/tags/${{ env.VERSION }}) | |
ASSET_ID=$(echo $RELEASE_DATA | jq -r ".assets | map(select(.name == \"${{ env.FILE_NAME }}\"))[0].id") | |
echo "FORMULA_ASSET_URL=https://api.github.com/repos/setopsco/releases/releases/assets/${ASSET_ID}" >> $GITHUB_ENV | |
- name: Download asset | |
run: | | |
curl -J -L -H "Accept: application/octet-stream" \ | |
${{ env.FORMULA_ASSET_URL }} \ | |
-o ${{ env.FILE_NAME }} | |
- name: Calculate file checksum | |
run: | | |
FILE_CHECKSUM=($(sha256sum ./${{ env.FILE_NAME }})) | |
echo "FORMULA_CHECKSUM=${FILE_CHECKSUM}" >> $GITHUB_ENV | |
- name: Update formula | |
run: | | |
sed -i 's|version \".*\"|version \"${{ env.FORMULA_VERSION }}\"|g' Formula/setops-cli.rb | |
sed -i 's|sha256 \".*\"|sha256 \"${{ env.FORMULA_CHECKSUM }}\"|g' Formula/setops-cli.rb | |
sed -i 's|url \".*\"|url \"${{ env.FORMULA_ASSET_URL }}\"|g' Formula/setops-cli.rb | |
sed -i 's|RELEASE_FILE_NAME = \".*\".freeze|RELEASE_FILE_NAME = \"${{ env.FORMULA_EXECUTABLE_NAME }}\".freeze|g' Formula/setops-cli.rb | |
- name: Validate changes | |
run: | | |
git diff | |
- name: Configure git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "SetOps GitHub Action" | |
- name: Commit formula update | |
run: | | |
git add --force Formula/setops-cli.rb | |
git commit -m ":arrow_up: Updates formula to ${{ env.VERSION }}" | |
- name: Push formula update | |
run: git push | |