Skip to content

fix actions reference #1

fix actions reference

fix actions reference #1

name: "Release Manager/Create Pre-release"
on:
workflow_call:
inputs:
pr_number:
type: string
description: 'PR number'
required: true
user:
type: string
description: 'User name'
default: 'github-actions[bot]'
package_jsons_to_rewrite:
type: string
description: 'package.jsons to rewrite (json)'
default: 'package.json'
permissions:
contents: write
issues: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
create-prerelease:
name: "Create Pre-release"
runs-on: ubuntu-latest
if: ${{ inputs.pr_number != '' }}
# 開いているリリースのパッチバージョンを上げる
steps:
- uses: actions/checkout@v4
- name: Initialize
uses: joinmisskey/release-actions/.github/actions/checkout-pr
with:
pr_number: ${{ inputs.pr_number }}
user: ${{ inputs.user }}
id: get_pr
- name: Get target version
uses: joinmisskey/release-actions/.github/actions/get-target-version
id: v
# バージョンをインクリメント
- name: Increment version
uses: actions/script@v7
env:
CURRENT_VERSION: ${{ steps.v.outputs.current_version }}
pr_is_draft: steps.get_pr.outputs.pr_is_draft
with:
script: |
const [major, minor, _patch, _pre] = process.env.CURRENT_VERSION.split('.');
const pre = Number(_pre);
if (Number.isNaN(pre)) {
console.error('Invalid pre version', process.env.CURRENT_VERSION, major, minor, _patch);
throw new Error('Invalid pre version');
}
if (process.env.pr_is_draft == 'true') {
if (_patch.endsWith('beta')) {
return `${major}.${minor}.${_patch}.${pre + 1}`;
}
return `${major}.${minor}.${_patch.split('-')[0]}-beta.${pre + 1}`;
}
if (_patch.endsWith('rc')) {
return `${major}.${minor}.${_patch}.${pre + 1}`;
}
return `${major}.${minor}.${_patch.split('-')[0]}-rc.${pre + 1}`;
result-encoding: string
id: release_version
# バージョンをpackage.jsonに書き込み
- name: Write version
uses: joinmisskey/release-actions/.github/actions/rewrite-package-json
with:
version: ${{ steps.release_version.outputs.result }}
package_jsons: ${{ inputs.package_jsons_to_rewrite }}
# release/ブランチにpush、タグを作成
- name: Commit version
run: |
git commit -am "Bump version to ${{ steps.release_version.outputs.result }}"
git push origin HEAD:release/${{ steps.v.outputs.target_version }}
git tag "${{ steps.release_version.outputs.result }}"
git push origin "${{ steps.release_version.outputs.result }}"
# CHANGELOG.mdの内容を取得
- name: Get changelog
uses: joinmisskey/release-actions/.github/actions/get-changelog
with:
version: ${{ steps.v.outputs.target_version }}
id: changelog
# リリースを作成
- name: Create release
run: |
gh release create "${{ steps.release_version.outputs.result }}" --prerelease --title "${{ steps.release_version.outputs.result }}" --notes "${{ steps.changelog.outputs.changelog }}"
# PRのnotesを更新
# (通常release-edit-with-pushで更新されているためここで更新されることはない)
#- name: Update PR
# run: |
# gh pr edit ${{ inputs.pr_number }} --body "${{ steps.changelog.outputs.changelog }}"