Merge branch 'citation-style-language:master' into master #2
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: Merge to release | |
on: | |
push: | |
branches: | |
- master | |
tags-ignore: | |
- '**' | |
workflow_dispatch: | |
inputs: | |
commit_message: | |
description: Commit message | |
required: true | |
permissions: {} | |
jobs: | |
release: | |
permissions: | |
contents: write # to create a release | |
pull-requests: read # to read pull requests (dorny/paths-filter) | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
DISTRIBUTION_UPDATER_TOKEN: "${{ secrets.DISTRIBUTION_UPDATER_TOKEN }}" | |
steps: | |
- uses: actions/checkout@v3 | |
if: github.event_name == 'push' | |
- uses: actions/checkout@v3 | |
if: github.event_name == 'workflow_dispatch' | |
with: | |
fetch-depth: 0 | |
- name: Release branch version | |
id: release | |
run: echo ::set-output name=branch::v1.0.2 | |
- name: Checkout release branch | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.release.outputs.branch }} | |
path: './release' | |
- name: Check for relevant changes | |
if: github.event_name == 'push' | |
uses: dorny/paths-filter@v3 | |
id: update | |
with: | |
list-files: shell | |
filters: | | |
updated: | |
- added|modified: [ '*.csl', 'dependent/*.csl', '*.xml', 'README.md' ] | |
deleted: | |
- deleted: [ '*.csl', 'dependent/*.csl', '*.xml' ] | |
workflows: | |
- added|modified: .github/workflows/*.yaml | |
updated_composer: | |
- added|modified: composer.json | |
deleted_composer: | |
- deleted: composer.json | |
- name: Changed files | |
if: github.event_name == 'push' | |
run: | | |
echo updated: ${{ steps.update.outputs.updated_files }} | |
echo deleted: ${{ steps.update.outputs.deleted_files }} | |
echo workflows: ${{ steps.update.outputs.workflows_files }} | |
- name: Set up Ruby | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true')) | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.0.2 | |
- name: but use cache to speed that up | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true')) | |
uses: actions/cache@v4 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Bundle install | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true')) | |
run: | | |
bundle config path vendor/bundle | |
bundle update sheldon --jobs 4 --retry 3 | |
- name: Populate new branch | |
run: bundle exec sheldon --token=$GITHUB_TOKEN --verbose --populate release | |
if: github.event_name == 'workflow_dispatch' | |
- name: update the timestamps and add the changes | |
run: bundle exec sheldon --token=$GITHUB_TOKEN --verbose --release release ${{ steps.update.outputs.updated_files }} | |
if: github.event_name == 'push' && steps.update.outputs.updated == 'true' | |
- name: delete deleted files | |
run: cd release && git rm ${{ steps.update.outputs.deleted_files }} | |
if: github.event_name == 'push' && steps.update.outputs.deleted == 'true' | |
- name: Update composer.json | |
if: steps.update.outputs.updated_composer == 'true' | |
run: | | |
cp composer.json release/composer.json | |
cd release | |
git add composer.json | |
- name: Delete composer.json | |
if: steps.update.outputs.deleted_composer == 'true' | |
run: | | |
cd release | |
git rm composer.json | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
repository: 'release' | |
commit_message: Releasing ${{ steps.update.outputs.updated_files }} ${{ steps.update.outputs.deleted_files }} ${{ steps.update.outputs.updated_composer_files }} ${{ steps.update.outputs.deleted_composer_files }} | |
if: github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true' || steps.update.outputs.updated_composer == 'true' || steps.update.outputs.deleted_composer == 'true') | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
repository: 'release' | |
commit_message: ${{ github.event.inputs.commit_message }} | |
if: github.event_name == 'workflow_dispatch' | |
# https://styles-update.zotero.org:8826/ is for Zotero (styles page, API's citation server, client style updates, etc.) | |
- name: ping Zotero servers | |
if: github.repository == 'citation-style-language/styles' | |
run: | | |
curl -H 'Content-Length:' -H "Authorization: $ZOTERO_UPDATE_TOKEN" -d 'payload={"type":"push","branch":"${{ steps.release.outputs.branch }}","status":0,"commit":"'$GITHUB_SHA'"}' https://styles-update.zotero.org:8826/ | |
- name: Copy workflows to locales repository | |
if: github.repository == 'citation-style-language/styles' && steps.update.outputs.workflows == 'true' | |
uses: drud/action-cross-commit@master | |
with: | |
source-folder: .github/workflows | |
destination-repository: https://csl-bot:${{ secrets.CSLBOT_TOKEN }}@github.com/citation-style-language/locales | |
destination-folder: .github/workflows | |
destination-branch: master | |
git-user: "csl-bot" | |
git-user-email: [email protected] | |
git-commit-message: copied ${{ steps.update.outputs.workflows_files }} from styles | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_bump: patch | |
if: github.event_name == 'push' && hashFiles('composer.json') != '' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true') | |
- name: Create a GitHub release | |
uses: softprops/action-gh-release@v1 | |
env: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag_version.outputs.new_tag }} | |
name: Release ${{ steps.tag_version.outputs.new_tag }} | |
body: Released ${{ steps.update.outputs.updated_files }} ${{ steps.update.outputs.deleted_files }} ${{ steps.update.outputs.updated_composer_files }} ${{ steps.update.outputs.deleted_composer_files }} | |
if: github.event_name == 'push' && hashFiles('composer.json') != '' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true') |