Skip to content

Commit

Permalink
ci: add release github action
Browse files Browse the repository at this point in the history
  • Loading branch information
kucaahbe committed Jan 24, 2024
1 parent 228f91b commit 5464dc1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 49 deletions.
23 changes: 3 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ name: 'Build'
on:
push:
branches: '**'
tags: 'v[0-9]+.[0-9]+.[0-9]+'

pull_request:
branches: 'main'

workflow_call:

# workflow_dispatch:
# inputs:
# verbose_build:
Expand Down Expand Up @@ -83,25 +84,7 @@ jobs:
key: ${{ steps.dub-packages-restore.outputs.cache-primary-key }}

- name: 'Upload binary'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: myrc-${{ matrix.os }}-${{ matrix.dc }}
path: myrc

start-release:
name: 'Schedule release'

needs: [build]
if: ${{ github.ref_type == 'tag' }}

runs-on: ubuntu-latest

permissions:
actions: write
contents: read

steps:
- uses: actions/checkout@v4
- run: gh workflow run release.yml -f version=MYTAG
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78 changes: 49 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,60 @@
name: Release
name: 'Release'

on:
push:
tags: 'v[0-9]+.[0-9]+.[0-9]+'

workflow_dispatch:
inputs:
version:
description: 'Release version'
description: 'Release version (vX.Y.Z)'
required: true
type: string
# workflow_run:
# workflows: [Build]
# types: [completed]
# push:
# tags: v**

permissions:
contents: write

jobs:
print-version:
build:
name: 'Build & Test'
uses: ./.github/workflows/build.yml

release:
name: 'Release'
needs: [build]
runs-on: ubuntu-latest
# if: ${{ inputs.print_tags }}
steps:
- name: Print the input version to STDOUT
run: echo The version is ${{ inputs.version }}
- name: Test debug message
run: echo "::debug::Set the Octocat variable"
# on-success:
# runs-on: ubuntu-latest
# #if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags/') }}
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
# steps:
# - env:
# TEST: ${{ github.ref_type }}
# run: 'echo "The triggering workflow passed: $TEST"'
# on-failure:
# runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'failure' }}
# steps:
# - run: echo 'The triggering workflow failed'
#
#
# https://github.com/marketplace/actions/publish-release
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4

- name: 'Set tag name'
id: tag
run: |
if [[ "${{ github.event_name }}" = "workflow_dispatch" ]]; then
tag="${{ inputs.version }}"
else
tag="${{ github.ref_name }}"
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: 'Create draft release (and upload release artifacts)'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for dir in $(ls -d1 myrc-*/); do
dir="${dir%/}"
chmod +x "$dir/myrc"
tar -czf "$dir.tar.gz" -C "$dir" myrc
done
tag="${{ steps.tag.outputs.tag }}"
#body="TODO"
#gh release create "$tag" --draft --generate-notes --notes "$body" *.tar.gz
gh release create "$tag" --draft --generate-notes *.tar.gz
# the "$tag" value is incorrect for draft release (the correct one
# returns previous gh release command)
#- name: 'Publish release'
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: gh release edit "$tag" --draft=false

0 comments on commit 5464dc1

Please sign in to comment.