Version up #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version up | |
on: | |
workflow_dispatch: | |
inputs: | |
semantic: | |
description: Semantic versioning | |
required: true | |
default: patch | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
permissions: | |
contents: write | |
actions: write | |
pull-requests: write | |
jobs: | |
version-up: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- id: generate_token | |
uses: tibdex/github-app-token@v1.8.0 | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.APP_PRIVATE_KEY }} | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
- name: Version up | |
id: version | |
run: | | |
set -x | |
version=$(npm --no-git-tag-version version $SEMANTIC) | |
echo "::set-output name=version::${version}" | |
sed -i -e "s|${GITHUB_REPOSITORY}@v[.0-9]\+|${GITHUB_REPOSITORY}@${version}|g" README.md | |
sed -i -e "s|${GITHUB_REPOSITORY}@v[.0-9]\+|${GITHUB_REPOSITORY}@${version}|g" .github/workflows/released.yml | |
git diff | |
env: | |
SEMANTIC: ${{ github.event.inputs.semantic }} | |
- uses: snow-actions/git-config-user@v1.0.0 | |
- name: Commit & PR | |
run: | | |
set -x | |
branch="release/${VERSION}" | |
git switch -c ${branch} | |
git add . | |
git commit -m "${VERSION}" | |
git push origin ${branch} | |
gh pr create --base ${GITHUB_REF_NAME} --head ${branch} --assignee ${GITHUB_ACTOR} --title ${VERSION} --body '' | |
env: | |
VERSION: ${{ steps.version.outputs.version }} | |
GH_TOKEN: ${{ steps.generate_token.outputs.token }} |