Skip to content

Commit

Permalink
[WIP] Added release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrancodes committed Oct 4, 2023
1 parent 32cdb31 commit 6f06263
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build & Release

on:
release:
types: [ published ]

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:v2
coverage: none

- name: Install Dependencies
run: |
composer install --no-dev --prefer-dist
- name: Set Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Build Binary
run: php harbor app:build --build-version=${{ env.RELEASE_VERSION }}

- name: Automatic Release
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs").promises;
const { repo: { owner, repo }, sha } = context;
const release = await github.repos.getReleaseByTag({
owner, repo,
tag: process.env.GITHUB_REF.replace("refs/tags/", ""),
});
console.log({ release });
await github.repos.uploadReleaseAsset({
owner, repo,
name: "harbor",
data: await fs.readFile("./builds/harbor"),
release_id: release.data.id,
});

0 comments on commit 6f06263

Please sign in to comment.