Skip to content

Commit

Permalink
Improve release and build workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
leotaku committed Feb 10, 2023
1 parent 0d3d577 commit 23c8f77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: build

on:
pull_request:
push:
branches:
- master
- 'releases/*'
tags: ['*']

jobs:
build:
Expand Down
42 changes: 18 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
name: release

on:
workflow_dispatch:
inputs:
name:
description: 'Release Name'
required: true
tag:
description: 'Tag'
required: true
run_id:
description: 'Build workflow run ID'
required: true
workflow_run:
workflows: [build]
types:
- completed

jobs:
create-release:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create Release
- name: Create release draft with assets
uses: actions/github-script@v6
id: create
env:
BRANCH: ${{ github.event.ref }}
NAME: ${{ github.event.inputs.name }}
TAG: ${{ github.event.inputs.tag }}
RUN_ID: ${{ github.event.inputs.run_id }}
with:
debug: true
script: |
const run = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.TAG,
target_commitish: process.env.BRANCH,
name: process.env.NAME,
tag_name: run.data.head_branch,
target_commitish: run.data.head_sha,
name: `Placeholder Release Name`,
draft: true,
generate_release_notes: true,
});
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: process.env.RUN_ID,
run_id: run.data.id,
});
for (const artifact of artifacts.data.artifacts) {
Expand Down

0 comments on commit 23c8f77

Please sign in to comment.