Skip to content

Fix git access credentials #12

Fix git access credentials

Fix git access credentials #12

name: Build and Release
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history so we can get all commits between tags
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
- name: Extract Version from Tag
run: echo "APP_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Set Version Number
run: |
agvtool new-marketing-version ${{ env.APP_VERSION }}
agvtool new-version -all ${{ github.run_number }}
- name: Build App
run: xcodebuild -project IPMenuBar.xcodeproj -scheme "IPMenuBar - Release" -configuration Release clean build -derivedDataPath './build' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
- name: Package App
run: |
FILE_NAME="IPMenuBar-${GITHUB_REF_NAME}.tar.gz"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
tar -czvf $FILE_NAME -C ./build/Build/Products/Release IPMenuBar.app
- name: Get Previous Tag
id: prev_tag
uses: WyriHaximus/github-action-get-previous-tag@v1
- name: Get Commit Messages
id: get_commits
run: |
commits=$(git log ${{ steps.prev_tag.outputs.tag }}..HEAD --oneline)
echo "::set-output name=commits::${commits}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
body: ${{ steps.get_commits.outputs.commits }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.FILE_NAME }}
asset_name: ${{ env.FILE_NAME }}
asset_content_type: application/gzip
- name: Update Homebrew Cask
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
# Configure Git
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
# Setup credentials for Git operations
git config --global credential.helper store
echo "https://$PERSONAL_ACCESS_TOKEN:[email protected]" > ~/.git-credentials
# Clone your tap repository
git clone https://github.com/janekbaraniewski/homebrew-janekbaraniewski.git
cd homebrew-janekbaraniewski
# Fetch the latest release data from GitHub API
RELEASE_DATA=$(curl -s -H "Authorization: token $PERSONAL_ACCESS_TOKEN" "https://api.github.com/repos/janekbaraniewski/IPMenuBar/releases/latest")
# Extract the version (tag name), removing the leading 'v'
APP_VERSION=$(echo $RELEASE_DATA | jq -r ".tag_name" | sed 's/^v//')
# Extract the tar.gz asset download URL
RELEASE_URL=$(echo $RELEASE_DATA | jq -r '.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url')
# Get the SHA256 checksum of the release asset
SHA256=$(curl -Ls $RELEASE_URL | shasum -a 256 | awk '{ print $1 }')
echo "Version: $APP_VERSION"
echo "URL: $RELEASE_URL"
echo "SHA256: $SHA256"
cat Casks/ipmenubar.rb
# Update the Cask file
sed -i '' "s|version ['\"].*['\"]|version \"$APP_VERSION\"|" Casks/ipmenubar.rb
sed -i '' "s|url ['\"].*['\"]|url \"$RELEASE_URL\"|" Casks/ipmenubar.rb
sed -i '' "s|sha256 ['\"].*['\"]|sha256 \"$SHA256\"|" Casks/ipmenubar.rb
echo "After sed:"
cat Casks/ipmenubar.rb
# Commit and push the changes
git add Casks/ipmenubar.rb
git commit -m "Update IPMenuBar to version $APP_VERSION"
git push origin master