Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Feature/semantic release #17

Merged
merged 3 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 44 additions & 15 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

env:
CARGO_TERM_COLOR: always
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

jobs:
check:
Expand All @@ -17,18 +18,21 @@ jobs:
runs-on: ${{ matrix.os }}
name: Run tests on ${{ matrix.os }}
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
id: rust-toolchain
with:
toolchain: stable

- name: Show Env
run: cargo --version

- name: Build
run: cargo build --verbose

- name: Run tests
- name: Cargo test
run: cargo test --verbose

test-release:
Expand All @@ -51,14 +55,27 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- name: Deploy
uses: actions-rs/toolchain@v1
token: ${{ secrets.GH_ACCESS_TOKEN }}

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
id: rust-toolchain
with:
toolchain: stable
override: true
- uses: katyo/publish-crates@v2

- name: Login on crates.io
uses: actions-rs/cargo@v1
with:
dry-run: true
command: login
args: ${{ secrets.CARGO_REGISTRY_TOKEN }}

- name: Release
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm install
npx semantic-release --dry-run

release:
if: github.event_name == 'push'
Expand All @@ -76,14 +93,26 @@ jobs:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.GH_ACCESS_TOKEN }}

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
id: rust-toolchain
with:
toolchain: stable

- name: Login on crates.io
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CARGO_REGISTRY_TOKEN }}

- name: Release
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "todo run Semantic Release"
# run: |
# npm install
# npx semantic-release
run: |
npm install
npx semantic-release

success:
runs-on: ubuntu-latest
Expand All @@ -98,4 +127,4 @@ jobs:
)
steps:
- name: Verify that there were no failures
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ Cargo.lock

# Intellij
/.idea
/node_modules/
/package-lock.json
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ homepage = "https://rustfields.github.io/"
documentation = "https://rustfields.github.io/"
repository = "https://github.com/RustFields/RuFi-core"
readme = "README.md"
authors = ["Filippo Vissani <[email protected]>", "Leonardo Micelli <[email protected]>", "Paolo Penazzi <[email protected]>", "Angela Cortecchia <[email protected]>"]

[dependencies]
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"devDependencies": {
"semantic-release-preconfigured-conventional-commits": "1.1.25"
},
"engines": {
"node": "18.16"
}
}
38 changes: 38 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const config = require('semantic-release-preconfigured-conventional-commits')
const verifyReleaseCommands = `
sed -i 's/version.*/version = "\${nextRelease.version}"/g' Cargo.toml || exit 1
git add -A || exit 2
git commit -m "chore(release)!: [skip ci] \${nextRelease.version} released" || exit 3
cargo publish --dry-run || exit 4
`
const prepareCommands = `
sed -i 's/version.*/version = "\${nextRelease.version}"/g' Cargo.toml || exit 1
git add -A || exit 2
git commit -m "chore(release)!: [skip ci] \${nextRelease.version} released" || exit 3
git push --force origin || exit 4
`
const publishCommands = `
git tag -a -f \${nextRelease.version} \${nextRelease.version} -F CHANGELOG.md || exit 1
git push --force origin \${nextRelease.version} || exit 2
cargo package || exit 3
cargo publish || exit 4
`
const releaseBranches = ["main"]
config.branches = releaseBranches
config.plugins.push(
["@semantic-release/exec", {
"prepareCmd": prepareCommands,
"publishCmd": publishCommands,
"verifyReleaseCmd": verifyReleaseCommands,
}],
["@semantic-release/github", {
"assets": [
{ "path": "target/package/*.crate" },
]
}],
["@semantic-release/git", {
"assets": ["CHANGELOG.md", "package.json"],
"message": "chore(release)!: [skip ci] ${nextRelease.version} released"
}],
)
module.exports = config