Skip to content

Commit

Permalink
fix?(release): リリース関連の調整
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyme committed Aug 12, 2024
1 parent c5fbb2f commit d208889
Showing 1 changed file with 51 additions and 25 deletions.
76 changes: 51 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@ on:
- labeled

jobs:
check_actor:
name: Check release actor
check_pr:
name: Check PR
runs-on: ubuntu-latest
steps:
- if: github.actor != github.repository_owner
run: exit 1
- name: Check release actor
if: github.actor != github.repository_owner
run: |
echo "::error::Only repository owner can create releases."
exit 1
- name: Check release label
if: github.event.label.name != 'release'
run: |
echo "::error::You need to specify the 'release' label to create releases."
exit 1
get_new_version:
name: Get new version
runs-on: ubuntu-latest
needs:
- check_actor
- check_pr
outputs:
version: ${{ steps.new_version.outputs.NEW_VERSION }}
steps:
Expand All @@ -29,29 +38,27 @@ jobs:
fetch-depth: 0

- name: Get latest tag
id: latest_tag
run: |
git fetch --prune
echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Get base version
id: base_version
run: |
echo "PREV_BASE_VERSION=$(echo ${{ github.env.LATEST_TAG }} | cut -d- -f1)" >> $GITHUB_ENV
echo "NEXT_BASE_VERSION=$(jq -r ${{ github.workspace }}/package.json '.version' | cut -d '-' -f 1)" >> $GITHUB_ENV
- name: Get prev base version
run: echo "PREV_BASE_VERSION=$(echo ${{ env.LATEST_TAG }} | cut -d- -f1)" >> $GITHUB_ENV

- name: Get next base version
run: echo "NEXT_BASE_VERSION=$(jq -r '${{ github.workspace }}/package.json' '.version' | cut -d- -f1)" >> $GITHUB_ENV

- name: Reset revision
if: github.env.PREV_BASE_VERSION != github.env.NEXT_BASE_VERSION
if: env.PREV_BASE_VERSION != env.NEXT_BASE_VERSION
run: echo "REVISION=0" >> $GITHUB_ENV

- name: Update revision
if: github.env.PREV_BASE_VERSION == github.env.NEXT_BASE_VERSION
run: echo "REVISION=$(($(echo ${{ github.env.LATEST_TAG }} | cut -d '-'' -f 2 | cut -d '.' -f 2) + 1))" >> $GITHUB_ENV
if: env.PREV_BASE_VERSION == env.NEXT_BASE_VERSION
run: echo "REVISION=$(($(echo ${{ env.LATEST_TAG }} | cut -d- -f2 | cut -d. -f2) + 1))" >> $GITHUB_ENV

- name: Build new version
id: new_version
run: |
echo "NEW_VERSION=${{ github.env.NEXT_BASE_VERSION }}-taiyme.${{ github.env.REVISION }}" >> $GITHUB_OUTPUT
run: echo "NEW_VERSION=${{ env.NEXT_BASE_VERSION }}-taiyme.${{ env.REVISION }}" >> $GITHUB_OUTPUT

update_package_json:
name: Update package.json
Expand All @@ -63,37 +70,56 @@ jobs:
uses: actions/checkout@v3

- name: Update package.json
run: jq '.version = "${{ needs.get_new_version.outputs.version }}"' "${{ github.workspace }}/package.json" --tab > tmp && mv tmp "${{ github.workspace }}/package.json"
run: jq ".version = '${{ needs.get_new_version.outputs.version }}'" "${{ github.workspace }}/package.json" --tab > tmp && mv tmp "${{ github.workspace }}/package.json"

- name: Upload package.json
uses: actions/upload-artifact@v3
with:
name: version_files
path: ${{ github.workspace }}/package.json

update_package_json_misskey_js:
name: Update package.json (misskey-js)
runs-on: ubuntu-latest
needs:
- get_new_version
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Update package.json (misskey-js)
run: jq ".version = '${{ needs.get_new_version.outputs.version }}'" "${{ github.workspace }}/packages/misskey-js/package.json" --tab > tmp && mv tmp "${{ github.workspace }}/packages/misskey-js/package.json"

- name: Upload package.json (misskey-js)
uses: actions/upload-artifact@v3
with:
name: version_files
path: ${{ github.workspace }}/packages/misskey-js/package.json

update_docker_compose_yml:
name: Update docker-compose.yml
name: Update compose.yml
runs-on: ubuntu-latest
needs:
- get_new_version
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Update docker-compose.yml
run: yq -r eval '.services.web.image = "ghcr.io/${{ github.repository }}:${{ needs.get_new_version.outputs.version }}"' -i "${{ github.workspace }}/docker-compose_example.yml"
- name: Update compose.yml
run: yq -r eval ".services.web.image = 'ghcr.io/${{ github.repository }}:${{ needs.get_new_version.outputs.version }}'" -i "${{ github.workspace }}/compose_example.yml"

- name: Upload docker-compose.yml
- name: Upload compose.yml
uses: actions/upload-artifact@v3
with:
name: version_files
path: ${{ github.workspace }}/docker-compose_example.yml
path: ${{ github.workspace }}/compose_example.yml

commit_tag_push:
name: Commit, Tag and Push
needs:
- get_new_version
- update_package_json
- update_package_json_misskey_js
- update_docker_compose_yml
runs-on: ubuntu-latest
steps:
Expand All @@ -117,20 +143,20 @@ jobs:
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git add .
git commit --author=. -m "${{ needs.get_new_version.outputs.version }}"
git commit --author=. -m "Release: ${{ needs.get_new_version.outputs.version }}"
git tag "${{ needs.get_new_version.outputs.version }}"
git push origin HEAD --follow-tags
merge_pr:
name: Merge Pull request
name: Merge PR
needs:
- commit_tag_push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: merge PR
- name: Merge PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down

0 comments on commit d208889

Please sign in to comment.