Skip to content

Commit

Permalink
workflow reworked
Browse files Browse the repository at this point in the history
- Replace unmaintained actions which used deprecated functions (Node.js 12,
  "set-output"), they may stop working soon:
  - https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
  - https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

- Remove all hardcoded version numbers:
  To trigger a release, push a tag that starts with 'v', e.g. 'v1.1'.
  The release and filenames will be named accordingly (with the 'v'
  stripped from filenames, e.g. 'gx_plugins_1.1_src.atr.bz2')

- Disable 'Latest' tag
  Normal pushes (without a tag) will create pre-releases named after its
  branch, e.g. 'master'. 'Latest' only pointed to the latest workflow-run,
  and could even refer to older codebases.

- This code is heavily based on the workflow file from the Aether project
  https://github.com/Dougal-s/Aether/blob/master/.github/workflows/build.yml
  • Loading branch information
torte71 authored Jan 24, 2023
1 parent 3be9fd7 commit 6cac8cd
Showing 1 changed file with 118 additions and 59 deletions.
177 changes: 118 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,84 @@
name: build

on: [push]
#on:
# push:
# tags:
# - 'v*'

env:
VERSION: "1.0"
defaults:
run:
shell: bash

jobs:
build:
####################
create-source-archive:
runs-on: ubuntu-20.04

outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
artifact-name: ${{ env.ARCHIVE_NAME }}

steps:
- name: Check out sources
uses: actions/[email protected]
with:
path: GxPlugins.lv2
submodules: recursive

- name: create source package
run: tar --exclude=.git* -cjf GxPlugins.tar.bz2 GxPlugins.lv2

- name: Set Archive Name
run: echo "ARCHIVE_NAME=gxplugins-source-code" >> "$GITHUB_ENV"

- uses: actions/[email protected]
with:
name: ${{ env.ARCHIVE_NAME }}
path: GxPlugins.tar.bz2

####################
build-linux:
runs-on: ubuntu-latest

outputs:
artifact-name: ${{ env.ARCHIVE_NAME }}

steps:
- name: remove tag
uses: dev-drprasad/delete-tag-and-release@master
- name: Check out sources
uses: actions/[email protected]
with:
delete_release: false
tag_name: Latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@master
- name: submodule update
run: git submodule update --init
- name: create source package
run: tar -C .. --exclude=.git* -cjf ../GxPlugins.tar.bz2 $(basename $(pwd))
submodules: recursive

- name: install lv2
run: |
sudo apt-get install lv2-dev debhelper fakeroot
- name: build deb
run: dpkg-buildpackage -rfakeroot -uc -us -b
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: Latest
release_name: Release latest
draft: false
prerelease: true
- name: Upload Release Asset (Source code)
id: upload-release-asset-src
uses: actions/upload-release-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ../GxPlugins.tar.bz2
asset_name: gxplugins_${{ env.VERSION }}_src.tar.bz2
asset_content_type: application
- name: Upload Release Asset (Debian package)
id: upload-release-asset-deb
uses: actions/upload-release-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: copy deb
run: cp ../gxplugins_*_amd64.deb .

- name: Set Archive Name
run: echo "ARCHIVE_NAME=gxplugins-linux" >> "$GITHUB_ENV"

- uses: actions/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ../gxplugins_${{ env.VERSION }}_amd64.deb
asset_name: gxplugins_${{ env.VERSION }}_amd64.deb
asset_content_type: application
name: ${{ env.ARCHIVE_NAME }}
path: gxplugins_*_amd64.deb

build-win:
needs: build
####################
build-windows:
runs-on: windows-latest

defaults:
run:
shell: msys2 {0}

outputs:
artifact-name: ${{ env.ARCHIVE_NAME }}

steps:
- uses: msys2/setup-msys2@v2
- name: Prepare MSys2
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
Expand All @@ -81,22 +91,71 @@ jobs:
mingw-w64-x86_64-pkgconf
pkgconf
mingw-w64-x86_64-7zip
- uses: actions/checkout@master
- name: submodule update
run: git submodule update --init
- name: Check out sources
uses: actions/[email protected]
with:
submodules: recursive

- name: make
run: make -j && make DESTDIR=$(pwd)/_bin install
- name: add license and readme
run: cp LICENSE README.md _bin~/.lv2/
- name: zip
run: mv _bin~/.lv2 _bin~/lv2 ; cd _bin~ ; 7z a -mx9 ../plugin.7z lv2 ; cd ..
- name: upload
id: upload-release-asset
uses: actions/upload-release-asset@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set Archive Name
run: echo "ARCHIVE_NAME=gxplugins-windows" >> "$GITHUB_ENV"

- uses: actions/[email protected]
with:
name: ${{ env.ARCHIVE_NAME }}
path: plugin.7z

####################
release:
runs-on: ubuntu-20.04

outputs:
tag-short: ${{ env.TAG_SHORT }}

needs:
- create-source-archive
- build-linux
- build-windows

steps:
- name: Set short tag name
run: |
TAG_SHORT=${{ github.ref_name }} # branch or tag
if [[ ${{ github.ref_type }} == 'tag' ]] \
&& [[ $TAG_SHORT =~ ^v[0-9] ]] ; then
TAG_SHORT=${TAG_SHORT:1} # remove leading 'v' from tag (v1.0 -> 1.0)
fi
echo "TAG_SHORT=$TAG_SHORT" >> "$GITHUB_ENV"
# required?
# - name: Move 'Latest' tag
# uses: richardsimko/[email protected]
# with:
# tag_name: Latest
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download all artifacts
uses: actions/[email protected]

- name: Create Archives
run: |
mv gxplugins-source-code/GxPlugins.tar.bz2 ./gxplugins_${{ env.TAG_SHORT }}_src.tar.bz2
mv gxplugins-linux/gxplugins_*_amd64.deb ./gxplugins_${{ env.TAG_SHORT }}_amd64.deb
mv gxplugins-windows/plugin.7z ./gxplugins_${{ env.TAG_SHORT }}_win64.7z
- uses: softprops/action-gh-release@v1
with:
upload_url: ${{ needs.build.outputs.upload_url }}
asset_path: plugin.7z
asset_name: gxplugins_${{ env.VERSION }}_win64.7z
asset_content_type: application
tag_name: ${{ github.ref_name }}
prerelease: true
files: |
gxplugins_${{ env.TAG_SHORT }}_src.tar.bz2
gxplugins_${{ env.TAG_SHORT }}_amd64.deb
gxplugins_${{ env.TAG_SHORT }}_win64.7z

0 comments on commit 6cac8cd

Please sign in to comment.