Skip to content

Commit

Permalink
Update CI script to run goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
oxplot committed Nov 7, 2022
1 parent d41c491 commit 376b9df
Showing 1 changed file with 24 additions and 80 deletions.
104 changes: 24 additions & 80 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,90 +1,34 @@
name: Build Static Binaries
on: [push]
name: goreleaser

jobs:
on:
push:
tags:
- '*'

build-linux-amd64:
name: Build Linux amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: '1.18'
- name: Dependencies
run: |
set -e
sudo apt update
sudo apt install -y libgtk-3-dev libglib2.0-dev libgdk-pixbuf2.0-dev
- name: Build
run: go build -o pdfrankenstein
- uses: actions/upload-artifact@v1
with:
name: linux-amd64
path: pdfrankenstein
permissions:
contents: write
# packages: write
# issues: write

release:
name: Release
needs: [build-linux-amd64]
jobs:
goreleaser:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v1
- name: Checkout
uses: actions/checkout@v2
with:
name: linux-amd64
- name: Compress artifacts
run: |
( cd linux-amd64; chmod +x pdfrankenstein; zip ../pdfrankenstein-linux-amd64.zip pdfrankenstein )
- uses: actions/setup-python@v1
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v2
with:
python-version: '3.x'
- uses: docker://ferrarimarco/github-changelog-generator:latest
go-version: 1.18
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: -u oxplot -p pdfrankenstein
- name: Generate Changelog
id: gen_changelog
env:
RELEASE_REF: ${{ github.ref }}
run: |
cat CHANGELOG.md
body="$(< CHANGELOG.md python -c '
import sys
import os
tag = os.getenv("RELEASE_REF").replace("refs/tags/", "")
in_block = False
for l in sys.stdin:
if l.startswith("## [%s]" % tag):
in_block = True
elif l.startswith("## ["):
in_block = False
if in_block:
sys.stdout.write(l)
')"
# https://github.com/actions/create-release/issues/25#issuecomment-575435307
body="${body//$'%'/%25}"
body="${body//$'\n'/%0A}"
body="${body//$'\r'/%0D}"
echo ref $RELEASE_REF
echo body $body
echo "::set-output name=release_body::$body"
- id: create_release
uses: actions/create-release@latest
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.gen_changelog.outputs.release_body }}
draft: true
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pdfrankenstein-linux-amd64.zip
asset_name: pdfrankenstein-linux-amd64.zip
asset_content_type: application/zip

0 comments on commit 376b9df

Please sign in to comment.