Files

267 lines
11 KiB
YAML

name: Release
on:
push:
tags:
- "v*"
jobs:
get_version:
name: Get version
runs-on: ubuntu-latest
steps:
- id: set_output
run: echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
outputs:
version: ${{ steps.set_output.outputs.version }}
test:
name: Run tests
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26.5"
cache: true
- run: go generate ./...
- run: go test -v -timeout 20m ./...
build:
name: Build
runs-on: macos-latest
needs: [get_version, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26.5"
cache: true
- run: go build -ldflags="-X github.com/majd/ipatool/v2/cmd.version=$VERSION" -o ipatool-$VERSION-windows-arm64.exe
env:
GOOS: windows
GOARCH: arm64
VERSION: ${{ needs.get_version.outputs.version }}
- run: go build -ldflags="-X github.com/majd/ipatool/v2/cmd.version=$VERSION" -o ipatool-$VERSION-windows-amd64.exe
env:
GOOS: windows
GOARCH: amd64
VERSION: ${{ needs.get_version.outputs.version }}
- run: go build -ldflags="-X github.com/majd/ipatool/v2/cmd.version=$VERSION" -o ipatool-$VERSION-macos-arm64
env:
GOOS: darwin
GOARCH: arm64
VERSION: ${{ needs.get_version.outputs.version }}
CGO_CFLAGS: -mmacosx-version-min=10.15
CGO_LDFLAGS: -mmacosx-version-min=10.15
CGO_ENABLED: 1
- run: go build -ldflags="-X github.com/majd/ipatool/v2/cmd.version=$VERSION" -o ipatool-$VERSION-macos-amd64
env:
GOOS: darwin
GOARCH: amd64
VERSION: ${{ needs.get_version.outputs.version }}
CGO_CFLAGS: -mmacosx-version-min=10.15
CGO_LDFLAGS: -mmacosx-version-min=10.15
CGO_ENABLED: 1
- uses: actions/upload-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe
path: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe
path: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
path: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
path: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
if-no-files-found: error
build_linux:
name: Build for Linux
runs-on: ${{ matrix.runner }}
needs: [get_version, test]
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
runner: ubuntu-24.04-arm
- arch: amd64
runner: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26.5"
cache: true
- run: go build -ldflags="-X github.com/majd/ipatool/v2/cmd.version=$VERSION" -o ipatool-$VERSION-linux-$GOARCH
env:
GOARCH: ${{ matrix.arch }}
VERSION: ${{ needs.get_version.outputs.version }}
- uses: actions/upload-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}
path: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}
if-no-files-found: error
build_ios:
name: Build for iOS
runs-on: macos-latest
needs: [get_version, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26.5"
cache: true
- run: brew install ldid cmake
- run: ./tools/build-ios.sh "ipatool-$VERSION-ios-arm64"
env:
VERSION: ${{ needs.get_version.outputs.version }}
- uses: actions/upload-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-ios-arm64
path: ipatool-${{ needs.get_version.outputs.version }}-ios-arm64
if-no-files-found: error
release_ios:
name: Release for iOS
runs-on: ubuntu-latest
needs: [get_version, build_ios, release_windows]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-ios-arm64
path: bin
- run: chmod +x "bin/$FILE" && tar -czvf "$FILE.tar.gz" "bin/$FILE"
env:
FILE: ipatool-${{ needs.get_version.outputs.version }}-ios-arm64
- run: ./tools/sha256sum.sh "$TARBALL" > "$TARBALL.sha256sum"
env:
TARBALL: ipatool-${{ needs.get_version.outputs.version }}-ios-arm64.tar.gz
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ipatool-${{ needs.get_version.outputs.version }}-ios-arm64.*
tag: ${{ github.ref }}
overwrite: false
file_glob: true
release_windows:
name: Release for Windows
runs-on: ubuntu-latest
needs: [get_version, build]
strategy:
fail-fast: false
matrix:
arch: [arm64, amd64]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.exe
path: bin
- run: tar -czvf $FILE.tar.gz bin/$FILE.exe
env:
FILE: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}
- run: ./tools/sha256sum.sh $TARBALL > $TARBALL.sha256sum
env:
TARBALL: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.tar.gz
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.*
tag: ${{ github.ref }}
overwrite: false
file_glob: true
release_linux:
name: Release for Linux
runs-on: ubuntu-latest
needs: [get_version, build_linux, release_windows]
strategy:
fail-fast: false
matrix:
arch: [arm64, amd64]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}
path: bin
- run: chmod +x bin/$FILE && tar -czvf $FILE.tar.gz bin/$FILE
env:
FILE: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}
- run: ./tools/sha256sum.sh $TARBALL > $TARBALL.sha256sum
env:
TARBALL: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}.tar.gz
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }}.*
tag: ${{ github.ref }}
overwrite: false
file_glob: true
release_macos:
name: Release for macOS
runs-on: ubuntu-latest
needs: [get_version, build, build_linux, release_windows, release_linux]
steps:
- uses: actions/checkout@v4
with:
path: ./ipatool
- uses: actions/download-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
path: bin
- run: chmod +x bin/$BIN && tar -czvf $BIN.tar.gz bin/$BIN && rm -rf bin/
env:
BIN: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
- uses: actions/download-artifact@v4
with:
name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
path: bin
- run: chmod +x bin/$FILE && tar -czvf $FILE.tar.gz bin/$FILE && rm -rf bin/
env:
FILE: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
- id: sha256
run: |
SHA256_ARM64=$(./ipatool/tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz)
SHA256_AMD64=$(./ipatool/tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz)
echo $SHA256_ARM64 > ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz.sha256sum
echo $SHA256_AMD64 > ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz.sha256sum
echo ::set-output name=sha256_arm64::$SHA256_ARM64
echo ::set-output name=sha256_amd64::$SHA256_AMD64
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ipatool-${{ needs.get_version.outputs.version }}-macos-*
tag: ${{ github.ref }}
overwrite: false
file_glob: true
- uses: actions/checkout@v4
with:
repository: ${{ secrets.HOMEBREW_REPO }}
ref: main
token: ${{ secrets.GH_TOKEN }}
path: homebrew-repo
- run: |
cd homebrew-repo
sed -i "3s/.*/ sha256 \"$SHA256_ARM64\"/" Casks/ipatool.rb
sed -i "4s/.*/ url \"https:\/\/github.com\/majd\/ipatool\/releases\/download\/v${{ needs.get_version.outputs.version }}\/ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz\"/" Casks/ipatool.rb
sed -i "5s/.*/ binary \"bin\/ipatool-${{ needs.get_version.outputs.version }}-macos-arm64\", target: \"ipatool\"/" Casks/ipatool.rb
sed -i "7s/.*/ sha256 \"$SHA256_AMD64\"/" Casks/ipatool.rb
sed -i "8s/.*/ url \"https:\/\/github.com\/majd\/ipatool\/releases\/download\/v${{ needs.get_version.outputs.version }}\/ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz\"/" Casks/ipatool.rb
sed -i "9s/.*/ binary \"bin\/ipatool-${{ needs.get_version.outputs.version }}-macos-amd64\", target: \"ipatool\"/" Casks/ipatool.rb
sed -i "12s/.*/ version \"${{ needs.get_version.outputs.version }}\"/" Casks/ipatool.rb
git config --local user.name ${{ secrets.GH_NAME }}
git config --local user.email ${{ secrets.GH_EMAIL }}
git add Casks/ipatool.rb
git commit -m "Update ipatool to v${{ needs.get_version.outputs.version }}"
git push "https://${{ secrets.GH_TOKEN }}@github.com/${{ secrets.HOMEBREW_REPO }}.git" --set-upstream "main"
env:
SHA256_ARM64: ${{ steps.sha256.outputs.sha256_arm64 }}
SHA256_AMD64: ${{ steps.sha256.outputs.sha256_amd64 }}