|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Determine next version |
| 22 | + id: version |
| 23 | + run: | |
| 24 | + LATEST_TAG=$(git tag --sort=-v:refname | head -n 1) |
| 25 | + if [ -z "$LATEST_TAG" ]; then |
| 26 | + NEXT_VERSION="0.0.1" |
| 27 | + else |
| 28 | + MAJOR=$(echo "$LATEST_TAG" | cut -d. -f1) |
| 29 | + MINOR=$(echo "$LATEST_TAG" | cut -d. -f2) |
| 30 | + PATCH=$(echo "$LATEST_TAG" | cut -d. -f3) |
| 31 | + NEXT_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" |
| 32 | + fi |
| 33 | + echo "tag=${NEXT_VERSION}" >> "$GITHUB_OUTPUT" |
| 34 | +
|
| 35 | + - name: Setup PHP |
| 36 | + uses: shivammathur/setup-php@v2 |
| 37 | + with: |
| 38 | + php-version: '8.1' |
| 39 | + extensions: mbstring, xml, curl |
| 40 | + tools: composer:v2 |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: composer install --no-dev --prefer-dist --optimize-autoloader |
| 44 | + |
| 45 | + - name: Download Box |
| 46 | + run: | |
| 47 | + curl -LSs https://box-project.github.io/box2/installer.php | php |
| 48 | + mv box.phar /usr/local/bin/box |
| 49 | + chmod +x /usr/local/bin/box |
| 50 | +
|
| 51 | + - name: Build phar |
| 52 | + run: php hypernode-api-cli app:build hypernode-api-cli --build-version=${{ steps.version.outputs.tag }} |
| 53 | + |
| 54 | + - name: Create tag |
| 55 | + run: | |
| 56 | + git config user.name "github-actions[bot]" |
| 57 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 58 | + git tag ${{ steps.version.outputs.tag }} |
| 59 | + git push origin ${{ steps.version.outputs.tag }} |
| 60 | +
|
| 61 | + - name: Create GitHub Release |
| 62 | + uses: softprops/action-gh-release@v2 |
| 63 | + with: |
| 64 | + tag_name: ${{ steps.version.outputs.tag }} |
| 65 | + name: v${{ steps.version.outputs.tag }} |
| 66 | + files: builds/hypernode-api-cli |
| 67 | + generate_release_notes: true |
0 commit comments