Skip to content

fix actions reference #1

fix actions reference

fix actions reference #1

Workflow file for this run

name: "Release Manager/Create Target"
on:
workflow_call:
inputs:
user:
type: string
description: 'User name'
default: 'github-actions[bot]'
version_increment_script:
type: string
description: 'Script to increment version'
default: |
#!/bin/bash
#
package_jsons_to_rewrite:
type: string
description: 'package.jsons to rewrite (json)'
default: 'package.json'
secrets:
RULESET_EDIT_APP_ID:
description: 'App ID for app to edit rulesets'
RULESET_EDIT_APP_PRIVATE_KEY:
description: 'Private key for app to edit rulesets'
permissions:
contents: write
issues: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
create-target:
name: "Create release branch, tag, and PR"
runs-on: ubuntu-latest
# 日付ベースでリリースを作成
steps:
- uses: actions/checkout@v4
- name: git config
run: |
git config --local user.email "${{ inputs.user }}@users.noreply.github.com"
git config --local user.name "${{ inputs.user }}"
# jqでpackage.jsonから現在のバージョンを取得
- name: Get current version
run: |
jq -r '.version' package.json
echo "current_version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
id: get_current_version
# バージョンをインクリメント
- name: Increment version
uses: actions/script@v7
env:
CURRENT_VERSION: ${{ steps.get_current_version.outputs.current_version }}
with:
script: ${{ inputs.version_increment_script }}
result-encoding: string
id: target_version
- name: beta 0
run: echo "result=${{ steps.target_version.outputs.result }}-beta.0" >> $GITHUB_OUTPUT
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 }}
# CHANGELOG.mdのUnreleasedの内容を取得
- name: Get changelog
uses: joinmisskey/release-actions/.github/actions/get-changelog
with:
version: Unreleased
id: changelog
# CHANGELOG.mdのバージョンの書き換え
- name: Modify CHANGELOG.md
run: |
sed -i 's/## Unreleased/## ${{ steps.target_version.outputs.result }}/' CHANGELOG.md
# release/ブランチとタグを作成
- name: Commit version
run: |
git commit -am "Bump version to ${{ steps.release_version.outputs.result }}"
git push origin HEAD:release/${{ steps.target_version.outputs.result }}
git tag "${{ steps.release_version.outputs.result }}"
git push origin "${{ steps.release_version.outputs.result }}"
# リリースを作成
- 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を作成
- name: Create PR
run: |
gh pr create --draft --title "Release: ${{ steps.target_version.outputs.result }}" --body "${{ steps.changelog.outputs.changelog }}" --head release/${{ steps.target_version.outputs.result }} --base ${{ github.ref_name }}
# rulesetを切り替え
- uses: actions/create-github-app-token@v1
id: app-token
if: vars.RULESET_ID_WITHIN_RELEASE || vars.RULESET_ID_OUT_OF_RELEASE
with:
app-id: ${{ secrets.RULESET_EDIT_APP_ID }}
private-key: ${{ secrets.RULESET_EDIT_APP_PRIVATE_KEY }}
- name: Enable the ruleset
uses: octokit/[email protected]
if: steps.app-token.outputs.token && vars.RULESET_ID_WITHIN_RELEASE
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
with:
route: PUT /repos/{repository}/rulesets/{ruleset_id}
repository: ${{ github.repository }}
ruleset_id: ${{ vars.RULESET_ID_WITHIN_RELEASE }}
enforcement: active
- name: Disable the ruleset
uses: octokit/[email protected]
if: steps.app-token.outputs.token && vars.RULESET_ID_OUT_OF_RELEASE
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
with:
route: PUT /repos/{repository}/rulesets/{ruleset_id}
repository: ${{ github.repository }}
ruleset_id: ${{ vars.RULESET_ID_OUT_OF_RELEASE }}
enforcement: disabled