Правки в Action #10
Workflow file for this run
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: Мастер выпуска предварительных редакций | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Клонирование репозитория | |
uses: actions/checkout@v2 | |
- name: Установка утилиты ZIP | |
run: sudo apt-get install -y zip | |
- name: Проверка последнего предварительного выпуска | |
id: get_latest_release | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const token = core.getInput("github-token"); | |
const headers = { | |
"Authorization": `token ${token}`, | |
"Accept": "application/vnd.github.v3+json" | |
}; | |
const response = await fetch(`https://api.github.com/repos/${context.repo.owner}/${context.repo.repo}/releases`, { | |
method: "GET", | |
headers: headers | |
}); | |
const releases = await response.json(); | |
let next_version; | |
if (releases.length === 0) { | |
next_version = 1; | |
} else { | |
const latestRelease = releases.find(release => release.tag_name.startsWith('dev')); | |
if (latestRelease) { | |
const latestVersion = parseInt(latestRelease.tag_name.replace('dev', '')); | |
next_version = latestVersion + 1; | |
} else { | |
next_version = 1; | |
} | |
} | |
core.setOutput('next_version', next_version); | |
- name: Создание архивов редакций для каждой из веток | |
run: | | |
for version in 1.16 1.17 1.18 1.19 1.20 1.21; do | |
zip -r Rus-For-Mods-$version-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip $version/assets $version/dynamicmcpack.json $version/pack.mcmeta pack.png PeruseOrBruise.txt | |
done | |
- name: Создание тега для выпуска | |
id: create_tag | |
run: | | |
tag_name="dev${{ steps.get_latest_release.outputs.next_version }}" | |
git tag $tag_name | |
git push origin $tag_name | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Создание выпуска | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: dev${{ steps.get_latest_release.outputs.next_version }} | |
release_name: Предварительная редакция №${{ steps.get_latest_release.outputs.next_version }} | |
draft: false | |
prerelease: false | |
- name: Загрузка архива ветки 1.16 в выпуск | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./Rus-For-Mods-1.16-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_name: Rus-For-Mods-1.16-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_content_type: application/zip | |
- name: Загрузка архива ветки 1.17 в выпуск | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./Rus-For-Mods-1.17-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_name: Rus-For-Mods-1.17-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_content_type: application/zip | |
- name: Загрузка архива ветки 1.18 в выпуск | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./Rus-For-Mods-1.18-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_name: Rus-For-Mods-1.18-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_content_type: application/zip | |
- name: Загрузка архива ветки 1.19 в выпуск | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./Rus-For-Mods-1.19-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_name: Rus-For-Mods-1.19-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_content_type: application/zip | |
- name: Загрузка архива ветки 1.20 в выпуск | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./Rus-For-Mods-1.20-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_name: Rus-For-Mods-1.20-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_content_type: application/zip | |
- name: Загрузка архива ветки 1.21 в выпуск | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./Rus-For-Mods-1.21-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_name: Rus-For-Mods-1.21-Dev-${{ steps.get_latest_release.outputs.next_version }}.zip | |
asset_content_type: application/zip |