diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 29e961d..3b79332 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,22 +1,54 @@ -name: Publish +name: Release + on: push: - tags: - - '*' + branches: + - main + pull_request: + branches: + - main jobs: build: - name: Publish binaries runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Build - run: cargo build --release - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: "{manifest.json,data.json}" - tag: ${{ github.ref }} - overwrite: true - file_glob: true + - uses: actions/checkout@v2 + - name: Extract version from commit message + id: ver + run: | + COMMIT_MESSAGE=$(git log -1 --pretty=%B) + echo "Commit message: $COMMIT_MESSAGE" + if [[ $COMMIT_MESSAGE =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "version=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT + else + echo "exit no version x.x.x in the commit message" + exit 1 + fi + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.ver.outputs.version }} + release_name: ${{ steps.ver.outputs.version }} + draft: false + prerelease: false + - name: Attach data.json + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: data.json + asset_name: data.json + asset_content_type: application/json + - name: Attach manifest.json + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: manifest.json + asset_name: manifest.json + asset_content_type: application/json