Skip to content

Commit

Permalink
fix: release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
shoriwe committed Jun 12, 2023
1 parent bd5b834 commit 414aa02
Showing 1 changed file with 25 additions and 48 deletions.
73 changes: 25 additions & 48 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,69 +35,46 @@ jobs:
name: Latest version
run: python version.py >> $GITHUB_OUTPUT

build:
create-release:
runs-on: ubuntu-latest
needs:
- versioning
steps:
- name: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.versioning.outputs.version }}
release_name: Release ${{ needs.versioning.outputs.version }}
draft: false
prerelease: false

build-release:
runs-on: ubuntu-latest
needs:
- create-release
strategy:
matrix:
os: [linux, windows, freebsd]
os: [linux, windows]
arch: [amd64, "386"]
steps:
- uses: actions/checkout@v3
- name: Prepare bin directory
run: mkdir -p bin
- name: Restore bin directory from cache
uses: actions/cache@v3
with:
path: bin
key: bin
- name: Build binary
run: go build -v -o bin/${{ github.event.repository.name }}.${{ matrix.os }}.${{ matrix.arch }}$(python -c "import os; print('.exe' if os.getenv('GOOS') == 'windows' else '', end='')")
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
- name: Save bin directory to cache
uses: actions/cache@v3
with:
path: bin
key: bin

upx:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Restore bin directory from cache
uses: actions/cache@v3
with:
path: bin
key: bin
- name: UPX
run: upx bin/*
- name: Save bin directory to cache
uses: actions/cache@v3
with:
path: bin
key: bin

release-github:
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
needs:
- upx
- versioning
steps:
- name: Restore bin directory from cache
uses: actions/cache@v3
with:
path: bin
key: bin
- name: GitHub release
uses: softprops/action-gh-release@v1
- name: Upload Binary to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
bin/*
tag_name: v${{needs.versioning.outputs.version}}
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./bin
asset_name: myapp_${{ matrix.os }}_${{ matrix.arch }}
asset_content_type: application/octet-stream

0 comments on commit 414aa02

Please sign in to comment.