feat(workflow): publishing pipeline (#399)

* Update and rename cargo-publish.yml to release-cargo.yml

* Update and rename npm-publish.yml to release-npm.yml

* Delete push-to-dev.yml

* Create pr-to-master.yml

* add newer packages to matrix

* check cargo published version

* skip cargo audit if versions match

* chore(release-cargo) tauri-cli renamed to tauri-bundler

Co-authored-by: Lucas Fernandes Nogueira <lucasfernandesnog@gmail.com>
This commit is contained in:
Jacob Bolda 2020-02-08 10:09:12 -06:00 committed by GitHub
parent cffda68b42
commit 2e8c65b4f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 226 additions and 55 deletions

View File

@ -1,23 +0,0 @@
name: Cargo Publish
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Crates.IO
run: cargo login ${{ secrets.crate_token }}
- name: Publish CLI
run: |
cd cli/tauri-bundler
echo "We will publish this directory."
ls # cargo publish
- name: Publish TAURI
run: |
cd tauri
echo "We will publish this directory."
ls # TAURI_DIST_DIR=../../test/fixture/dist cargo publish

View File

@ -1,18 +0,0 @@
name: NPM Publish
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to NPM
run: npm login ${{ secrets.npm_token }}
- name: Publish package
run: |
cd packages/tauri-js
echo "We will publish this directory."
ls # npm publish

32
.github/workflows/pr-to-master.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: pr-to-master
on:
push:
branches:
- dev
jobs:
pr-to-master:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, 'version updates')
steps:
- uses: actions/checkout@v2
with:
ref: master
- name: git config
run: |
git config --global user.name "${{ github.event.pusher.name }}"
git config --global user.email "${{ github.event.pusher.email }}"
- run: git fetch origin dev
- run: git read-tree -u --reset ${{ github.sha }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: ${{ github.event.head_commit.message }}
branch: release/master
branch-suffix: short-commit-hash
title: Publish
body: |
Merging this PR will squash and push all changes to the master branch.
It will kick off the process to release and publish any packages with an incremented version number.

View File

@ -1,14 +0,0 @@
name: dev push
on:
push:
branches:
- dev
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

105
.github/workflows/release-cargo.yml vendored Normal file
View File

@ -0,0 +1,105 @@
name: release-cargo
on:
push:
branches:
- master
paths:
- '**/Cargo.toml'
jobs:
publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- name: tauri-bundler
registryName: tauri-bundler
path: cli/tauri-bundler
publishPath: /target/package
- name: tauri-core
registryName: tauri
path: tauri
publishPath: /target/package
- name: tauri-api
registryName: tauri-api
path: tauri-api
- name: tauri-updater
registryName: tauri-updater
path: tauri-updater
- name: tauri-utils
registryName: tauri-utils
path: tauri-utils
steps:
- uses: actions/checkout@v2
with:
ref: master
toolchain: stable
- name: install webkit2gtk
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- name: get version
working-directory: ${{ matrix.package.path }}
run: echo ::set-env name=PACKAGE_VERSION::$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml)
- name: check published version
run: echo ::set-env name=PUBLISHED_VERSION::$(cargo search ${{ matrix.package.registryName }} --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -)
- name: cargo package
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
run: |
echo "package dir:"
ls
cargo package
echo "We will publish:" $PACKAGE_VERSION
echo "This is current latest:" $PUBLISHED_VERSION
echo "post package dir:"
cd ${{ matrix.publishPath }}
ls
- name: cargo audit
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
run: |
cargo install cargo-audit
echo "# Cargo Audit" | tee -a ${{runner.workspace }}/notes.md
cargo audit 2>&1 | tee -a ${{runner.workspace }}/notes.md
- name: Publish ${{ matrix.package.name }}
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
run: |
echo "# Cargo Publish" | tee -a ${{runner.workspace }}/notes.md
cargo publish 2>&1 | tee -a ${{runner.workspace }}/notes.md
- name: Create Release
id: create_crate_release
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
uses: jbolda/create-release@v1.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ matrix.package.name }}-v${{ env.PACKAGE_VERSION }}
release_name: "Release ${{ matrix.package.name }} v${{ env.PACKAGE_VERSION }} [crates.io]"
bodyFromFile: ./../notes.md
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_crate_release.outputs.upload_url }}
asset_path: ./${{ matrix.package.publishPath }}/${{ matrix.package.registryName }}-${{ env.PACKAGE_VERSION }}.crate
asset_name: ${{ matrix.package.registryName }}-${{ env.PACKAGE_VERSION }}.crate
asset_content_type: application/x-gtar
- name: Tangle Release
id: tangle_release
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
uses: iotaledger/gh-tangle-release@v0.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IOTA_SEED: ${{ secrets.IOTA_SEED }}
with:
tag_name: ${{ matrix.package.name }}-v${{ env.PACKAGE_VERSION }}
comment: "[Test] Release ${{ matrix.package.name }} v${{ env.PACKAGE_VERSION }} [crates.io]"

89
.github/workflows/release-npm.yml vendored Normal file
View File

@ -0,0 +1,89 @@
name: release-npm
on:
push:
branches:
- master
paths:
- '**/package.json'
jobs:
publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- name: tauri.js
registryName: tauri
path: cli/tauri.js
steps:
- uses: actions/checkout@v2
with:
ref: master
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- name: get version
working-directory: ${{ matrix.package.path }}
run: echo ::set-env name=PACKAGE_VERSION::$(node -p "require('./package.json').version")
- name: check published version
run: echo ::set-env name=PUBLISHED_VERSION::$(npm view ${{ matrix.package.registryName }} version)
- name: npm pack
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
run: |
echo "pack dir:"
ls
npm pack
echo "We will publish:" $PACKAGE_VERSION
echo "This is current latest:" $PUBLISHED_VERSION
echo "post pack dir:"
ls
- name: npm audit
working-directory: ${{ matrix.package.path }}
run: |
echo "# NPM Audit Results" | tee -a ${{runner.workspace }}/notes.md
npm audit 2>&1 | tee -a ${{runner.workspace }}/notes.md
- name: Publish ${{ matrix.package.name }}
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
working-directory: ${{ matrix.package.path }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "# NPM Package Publish" | tee -a ${{runner.workspace }}/notes.md
npm publish 2>&1 | tee -a ${{runner.workspace }}/notes.md
- name: Create Release
id: create_npm_release
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
uses: jbolda/create-release@v1.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ matrix.package.name }}-v${{ env.PACKAGE_VERSION }}
release_name: "Release ${{ matrix.package.name }} v${{ env.PACKAGE_VERSION }} [npmjs.com]"
bodyFromFile: ./../notes.md
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_npm_release.outputs.upload_url }}
asset_path: ./${{ matrix.package.path }}/${{ matrix.package.registryName }}-${{ env.PACKAGE_VERSION }}.tgz
asset_name: ${{ matrix.package.registryName }}-${{ env.PACKAGE_VERSION }}.tgz
asset_content_type: application/x-gtar
- name: Tangle Release
id: tangle_release
if: env.PACKAGE_VERSION != env.PUBLISHED_VERSION
uses: iotaledger/gh-tangle-release@v0.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IOTA_SEED: ${{ secrets.IOTA_SEED }}
with:
tag_name: ${{ matrix.package.name }}-v${{ env.PACKAGE_VERSION }}
comment: "[Test] Release ${{ matrix.package.name }} v${{ env.PACKAGE_VERSION }} [npmjs.com]"