forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
name: Make Release | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- release | ||
types: | ||
- labeled | ||
|
||
jobs: | ||
check_actor: | ||
name: Check release actor | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: github.actor != github.repository_owner | ||
run: exit 1 | ||
|
||
get_new_version: | ||
name: Get new version | ||
runs-on: ubuntu-latest | ||
needs: | ||
- check_actor | ||
outputs: | ||
version: ${{ steps.new_version.outputs.NEW_VERSION }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get latest tag | ||
id: latest_tag | ||
run: | | ||
git fetch --prune --depth=1 | ||
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 package.json '.version' | cut -d '-' -f 1)" >> $GITHUB_ENV | ||
- name: Reset revision | ||
if: github.env.PREV_BASE_VERSION != github.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 | ||
|
||
- name: Build new version | ||
id: new_version | ||
run: | | ||
echo "NEW_VERSION=${{ github.env.NEXT_BASE_VERSION }}-taiyme.${{ github.env.REVISION }}" >> $GITHUB_OUTPUT | ||
update_package_json: | ||
name: Update package.json | ||
runs-on: ubuntu-latest | ||
needs: | ||
- get_new_version | ||
steps: | ||
- name: Checkout | ||
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" | ||
|
||
- name: Upload package.json | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: version_files | ||
path: ${{ github.workspace }}/package.json | ||
|
||
update_docker_compose_yml: | ||
name: Update docker-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: Upload docker-compose.yml | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: version_files | ||
path: ${{ github.workspace }}/docker-compose_example.yml | ||
|
||
commit_tag_push: | ||
name: Commit, Tag and Push | ||
needs: | ||
- get_new_version | ||
- update_package_json | ||
- update_docker_compose_yml | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Download files | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: version_files | ||
|
||
- name: Check change | ||
id: is_chnage | ||
run: echo "is_change=$(git status -s | wc -l)" >> $GITHUB_OUTPUT | ||
|
||
- name: Commit and Tag | ||
if: steps.is_chnage.outputs.is_change != '0' | ||
run: | | ||
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 tag "${{ needs.get_new_version.outputs.version }}" | ||
git push origin HEAD --follow-tags | ||
merge_pr: | ||
name: Merge Pull request | ||
needs: | ||
- commit_tag_push | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: merge PR | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
gh pr merge ${{ github.event.pull_request.number }} --merge | ||
release: | ||
name: Release | ||
needs: | ||
- get_new_version | ||
- merge_pr | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout release branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.base_ref }} | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ needs.get_new_version.outputs.version }} | ||
body: ${{ github.event.pull_request.body }} |
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