Skip to content

Commit

Permalink
ci: enable release and asset upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed Feb 27, 2024
1 parent bd67a9a commit c9f7d6e
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 5 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ permissions:
jobs:
build:
runs-on: ${{ matrix.os }}
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
Expand All @@ -38,10 +40,15 @@ jobs:
override: true
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: doclytics-${{ env.BRANCH_NAME }}-${{ matrix.os }}
path: |
./target/${{ matrix.target }}/release/doclytics${{ matrix.os == 'windows-latest' && '.exe' || '' }}
build-docker:
needs: build
runs-on: ubuntu-latest
if: ${{ github.ref }} != 'master' && ${{ github.ref }} != 'development'
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
Expand All @@ -68,7 +75,7 @@ jobs:
contents: write
issues: write
pull-requests: write
if: false #${{ github.ref }} == 'master' || ${{ github.ref }} == 'development'
if: ${{ github.ref }} == 'master' || ${{ github.ref }} == 'development'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/release-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,46 @@ env:
CI: true

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
override: true
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: doclytics-${{ env.BRANCH_NAME }}-${{ matrix.os }}
path: |
./target/${{ matrix.target }}/release/doclytics${{ matrix.os == 'windows-latest' && '.exe' || '' }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
if: ${{ github.ref }} != 'master' && ${{ github.ref }} != 'development'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./target/${{ matrix.target }}/release/doclytics${{ matrix.os == 'windows-latest' && '.exe' || '' }}
asset_name: doclytics-${{ env.BRANCH_NAME }}-${{ matrix.os }}
asset_content_type: application/octet-stream}
build-docker:
needs: build
runs-on: ubuntu-latest
Expand Down
76 changes: 73 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,47 @@ env:
CI: true

jobs:

build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
override: true
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: doclytics-${{ env.BRANCH_NAME }}-${{ matrix.os }}
path: |
./target/${{ matrix.target }}/release/doclytics${{ matrix.os == 'windows-latest' && '.exe' || '' }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
if: ${{ github.ref }} != 'master' && ${{ github.ref }} != 'development'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./target/${{ matrix.target }}/release/doclytics${{ matrix.os == 'windows-latest' && '.exe' || '' }}
asset_name: doclytics-${{ env.BRANCH_NAME }}-${{ matrix.os }}
asset_content_type: application/octet-stream
build-docker:
needs: build
runs-on: ubuntu-latest
if: ${{ github.ref }} != 'master' && ${{ github.ref }} != 'development'
env:
Expand All @@ -37,4 +75,36 @@ jobs:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/doclytics:${{ env.BRANCH_NAME }}
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64
- name: Upload macOS Binary
uses: actions/upload-release-asset@v1
if: steps.semantic-release.outputs.release_created == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.semantic-release.outputs.release_upload_url }}
asset_path: ./target/x86_64-apple-darwin/release/your-binary
asset_name: your-binary-macos
asset_content_type: application/octet-stream

- name: Upload Windows Binary
uses: actions/upload-release-asset@v1
if: steps.semantic-release.outputs.release_created == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.semantic-release.outputs.release_upload_url }}
asset_path: ./target/x86_64-pc-windows-msvc/release/your-binary.exe
asset_name: your-binary-windows.exe
asset_content_type: application/octet-stream

- name: Upload Linux Binary
uses: actions/upload-release-asset@v1
if: steps.semantic-release.outputs.release_created == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.semantic-release.outputs.release_upload_url }}
asset_path: ./target/x86_64-unknown-linux-gnu/release/your-binary
asset_name: your-binary-linux
asset_content_type: application/octet-stream

0 comments on commit c9f7d6e

Please sign in to comment.