Skip to content

Commit

Permalink
Correct syntax reuse workflow github action
Browse files Browse the repository at this point in the history
  • Loading branch information
hiento09 committed Jan 16, 2024
1 parent 6a8bea0 commit f85d475
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 129 deletions.
54 changes: 36 additions & 18 deletions .github/workflows/build-linux-x64.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
jobs:
delete-cloudflare-r2-folder:
name: build-linux-x64
on:
workflow_call:
inputs:
ref:
required: true
Expand All @@ -9,15 +10,32 @@ jobs:
required: true
type: boolean
default: false
condition:
required: false
type: string
default: 'github.ref == ''refs/heads/main'''
upload_cloudflare_r2:
required: true
type: boolean
default: false
new-version:
required: true
type: string
default: ''
secrets:
CLOUDFLARE_R2_PUBLIC_URL:
required: false
CLOUDFLARE_R2_BUCKET_NAME:
required: false
CLOUDFLARE_R2_ACCESS_KEY_ID:
required: false
CLOUDFLARE_R2_SECRET_ACCESS_KEY:
required: false
CLOUDFLARE_ACCOUNT_ID:
required: false
GITHUB_TOKEN:
required: false

jobs:
build-linux-x64:
runs-on: ubuntu-latest
environment: production
permissions:
contents: write
steps:
Expand All @@ -38,9 +56,9 @@ jobs:
id: version_update
run: |
# Update the version in electron/package.json
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json
jq --arg version "${{ inputs.new-version }}" '.version = $version' electron/package.json > /tmp/package.json
mv /tmp/package.json electron/package.json
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json
jq --arg version "${{ inputs.new-version }}" '.version = $version' web/package.json > /tmp/package.json
mv /tmp/package.json web/package.json
jq '.build.publish = [{"provider": "generic", "url": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json
mv /tmp/package.json electron/package.json
Expand All @@ -54,25 +72,25 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}-deb
name: jan-linux-amd64-${{ inputs.new-version }}-deb
path: ./electron/dist/*.deb

- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}-AppImage
name: jan-linux-amd64-${{ inputs.new-version }}-AppImage
path: ./electron/dist/*.AppImage
${{ if eq(parameters.upload_cloudflare_r2, true) }}- name: put-object using awscli s3api
${{ if eq(parameters.enable_condition, true) }}if: ${{ parameters.condition }}

- name: put-object using awscli s3api
if: eq(${{ inputs.upload_cloudflare_r2 }}, true)
run: |
ls -al ./electron/dist
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ needs.get-update-version.outputs.new_version }}.AppImage" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-amd64-${{ inputs.new-version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ inputs.new-version }}.deb" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-linux-amd64-${{ inputs.new-version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ inputs.new-version }}.deb" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --body "./electron/dist/jan-linux-x86_64-${{ inputs.new-version }}.AppImage" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
Expand Down
79 changes: 52 additions & 27 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
jobs:
delete-cloudflare-r2-folder:
name: build-linux-x64
on:
workflow_call:
inputs:
environment:
required: true
type: string
default: 'production'
ref:
required: true
type: string
Expand All @@ -13,21 +10,49 @@ jobs:
required: true
type: boolean
default: false
condition:
required: false
type: string
default: 'github.ref == ''refs/heads/main'''
upload_cloudflare_r2:
required: true
type: boolean
default: false
new-version:
required: true
type: string
default: ''
secrets:
CLOUDFLARE_R2_PUBLIC_URL:
required: false
CLOUDFLARE_R2_BUCKET_NAME:
required: false
CLOUDFLARE_R2_ACCESS_KEY_ID:
required: false
CLOUDFLARE_R2_SECRET_ACCESS_KEY:
required: false
CLOUDFLARE_ACCOUNT_ID:
required: false
GITHUB_TOKEN:
required: false
CODE_SIGN_P12_BASE64:
required: false
CODE_SIGN_P12_PASSWORD:
required: false
APPLE_ID:
required: false
APPLE_APP_SPECIFIC_PASSWORD:
required: false
DEVELOPER_ID:
required: false

jobs:
build-macos:
runs-on: macos-latest
environment: ${{ parameters.environment }}
environment: production
permissions:
contents: write
steps:
- name: Getting the repo
uses: actions/checkout@v3
with:
ref: ${{ parameters.ref }}
ref: ${{ inputs.ref }}

- name: Installing node
uses: actions/setup-node@v1
Expand All @@ -42,10 +67,10 @@ jobs:
id: version_update
run: |
# Update the version in electron/package.json
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json
jq --arg version "${{ inputs.new-version }}" '.version = $version' electron/package.json > /tmp/package.json
mv /tmp/package.json electron/package.json
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json
jq --arg version "${{ inputs.new-version }}" '.version = $version' web/package.json > /tmp/package.json
mv /tmp/package.json web/package.json
jq '.build.publish = [{"provider": "generic", "url": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json
Expand Down Expand Up @@ -79,27 +104,27 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}
path: ./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg
name: jan-mac-x64-${{ inputs.new-version }}
path: ./electron/dist/jan-mac-x64-${{ inputs.new-version }}.dmg

- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}
path: ./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg
name: jan-mac-arm64-${{ inputs.new-version }}
path: ./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.dmg

${{ if eq(parameters.upload_cloudflare_r2, true) }}- name: put-object using awscli s3api
${{ if eq(parameters.enable_condition, true) }}if: ${{ parameters.condition }}
- name: put-object using awscli s3api
if: eq(${{ inputs.upload_cloudflare_r2 }}, true)
continue-on-error: true
run: |
ls -al ./electron/dist
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.zip" --content-type "application/zip"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.zip" --content-type "application/zip"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ inputs.new-version }}.zip" --body "./electron/dist/jan-mac-x64-${{ inputs.new-version }}.zip" --content-type "application/zip"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ inputs.new-version }}.zip" --body "./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.zip" --content-type "application/zip"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-mac-x64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/jan-mac-arm64-${{ inputs.new-version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ inputs.new-version }}.dmg" --content-type "application/octet-stream"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ inputs.new-version }}/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml"
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
Expand Down
Loading

0 comments on commit f85d475

Please sign in to comment.