Fully automate release process #9
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: Release | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
- run: npm i -g @apidevtools/swagger-cli@4 | |
- name: Update Spec version | |
run: "sed -i 's/version: \"Dev/version: \"${{ github.ref_name }}/' ./beacon-node-oapi.yaml" | |
- name: Bundle yaml spec | |
run: "swagger-cli bundle ./beacon-node-oapi.yaml -r -t yaml -o ./deploy/beacon-node-oapi.yaml" | |
- name: Bundle json spec | |
run: "swagger-cli bundle ./beacon-node-oapi.yaml -r -t json -o ./deploy/beacon-node-oapi.json" | |
- name: Update index.html | |
run: | | |
sed -i "/urls:/a \ {url: \"./releases/${{ github.ref_name }}/beacon-node-oapi.json\", name: \"${{ github.ref_name }}\"}," ./index.html | |
- name: Update Changelog | |
run: | | |
sed -i "s/## Development Version/## ${{ github.ref_name }}/" ./CHANGES.md | |
awk '/# Recent Changes/ {print; print ""; system("cat development_version_template.md"); next}1' CHANGES.md > temp && mv temp CHANGES.md | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b release-${{ github.ref_name }} | |
git add index.html CHANGES.md | |
git commit -m "Release ${{ github.ref_name }}" | |
git push origin release-${{ github.ref_name }} | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Release ${{ github.ref_name }}" | |
branch: release-${{ github.ref_name }} | |
title: "Release ${{ github.ref_name }}" | |
body: "" | |
base: master | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
name: ${{ github.ref_name }} | |
tag_name: ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
files: | | |
./deploy/beacon-node-oapi.yaml | |
./deploy/beacon-node-oapi.json | |
fail_on_unmatched_files: true | |
- name: Rollback Release | |
if: failure() | |
uses: author/[email protected] | |
with: | |
# Using a known release ID | |
release_id: ${{ steps.create_release.outputs.id }} | |
# Using a tag name | |
tag: ${{ github.ref }} | |
# Remove the tag if release process failed | |
delete_orphan_tag: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |