Skip to content

Commit

Permalink
feat: use semantic versioning to create semantic releases and changel…
Browse files Browse the repository at this point in the history
…og.md file
  • Loading branch information
grinish21 committed Sep 6, 2022
1 parent 171d986 commit e9f05e3
Showing 1 changed file with 38 additions and 76 deletions.
114 changes: 38 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,65 @@ on:
name: Release EarlyBird

jobs:
build:
name: Build and Tag
get_next_version:
runs-on: ubuntu-latest
name: Get next version
outputs:
new_tag: ${{ steps.bump-version.outputs.new_tag }}
earlybird_next_version: ${{ steps.getversion.outputs.earlybird_next_version }}
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Get version for next release
id: getversion
run: |
echo "::set-output name=earlybird_next_version::$(npx -p @semantic-release/changelog -p @semantic-release/git -p [email protected] semantic-release --no-ci --dry-run | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: get_next_version
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
go-version: ^1.18
- name: Checkout repo
uses: actions/checkout@v2
- name: Build project
run: ./build.sh
run: ./build.sh ${{ needs.get_next_version.outputs.earlybird_next_version }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: earlybird-binaries
path: ./binaries/
if-no-files-found: error
- name: Bump version and push tag
id: bump-version
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
RELEASE_BRANCHES: .*
INITIAL_VERSION: 2.0.0
release:
needs: build
needs:
- get_next_version
- build
name: Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Create Release
id: create-release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.build.outputs.new_tag }}
draft: false
prerelease: false
publishLinux:
needs: [build, release]
name: Publish Linux Asset
runs-on: ubuntu-latest
steps:
- name: Download earlybird artifacts
uses: actions/download-artifact@v2
with:
name: earlybird-binaries
- name: Upload Linux Release Asset
id: upload-linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: go-earlybird-linux
asset_name: go-earlybird-linux
asset_content_type: application/octet-stream
publishmacOS:
needs: [build, release]
name: Publish MacOS Asset
runs-on: ubuntu-latest
steps:
- name: Download earlybird artifacts
uses: actions/download-artifact@v2
- uses: actions/checkout@v2
with:
name: earlybird-binaries
- name: Upload macOS Release Asset
id: upload-macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: go-earlybird
asset_name: go-earlybird-macos
asset_content_type: application/octet-stream
publishWindows:
needs: [build, release]
name: Publish Windows Asset
runs-on: ubuntu-latest
steps:
token: ${{ secrets.GITHUB_TOKEN}}
- name: Download earlybird artifacts
uses: actions/download-artifact@v2
- name: Copy artifacts to current directory
run: mv earlybird-binaries/* .
- name: Rename macOS binary
run: mv go-earlybird go-earlybird-macos
- name: Print current directory
run: ls -lah
- uses: actions/setup-node@v2
with:
name: earlybird-binaries
- name: Upload Windows Release Asset
id: upload-windows
uses: actions/upload-release-asset@v1
node-version: '16'
- name: Create a release with Semantic Release
run: npx -p @semantic-release/changelog -p @semantic-release/git -p [email protected] semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: go-earlybird.exe
asset_name: go-earlybird.exe
asset_content_type: application/x-msdownload
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit e9f05e3

Please sign in to comment.