Release #147
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 and Publish | |
on: | |
workflow_dispatch | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
extract-version: | |
name: Extract Version | |
runs-on: ubuntu-latest | |
outputs: | |
cargo_version: ${{ steps.extract.outputs.cargo_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract version from Cargo.toml | |
id: extract | |
run: | | |
version=$(grep '^version =' Cargo.toml | sed 's/version = "//' | sed 's/"//') | |
echo "Extracted version: $version" | |
if [ -z "$version" ]; then | |
echo "Error: Version is blank." | |
exit 1 | |
fi | |
echo "### Release Build: v$version" >> $GITHUB_STEP_SUMMARY | |
echo "cargo_version=$version" >> $GITHUB_OUTPUT | |
build-jobs: | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: linux | |
arch: x64 | |
ext: tar.gz | |
on: ubuntu-latest | |
artifact: paseto_cli-linux-x64 | |
- target: x86_64-apple-darwin | |
os: darwin | |
arch: x64 | |
ext: tar.gz | |
on: macos-latest | |
artifact: paseto_cli-darwin-x64 | |
# - target: aarch64-apple-darwin | |
# os: darwin | |
# arch: aarch64 | |
# ext: tar.gz | |
# on: macos-latest | |
# artifact: paseto_cli-darwin-aarch64 | |
# - target: x86_64-pc-windows-msvc | |
# os: win32 | |
# arch: x64 | |
# ext: zip | |
# on: windows-latest | |
# artifact: paseto_cli-win32-x64 | |
runs-on: ${{ matrix.on }} | |
env: | |
filename: ${{ matrix.artifact }}.${{ matrix.ext }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Package Binary | |
run: | | |
cd target/${{ matrix.target }}/release | |
if [[ "${{ matrix.os }}" == "win32" ]]; then | |
7z a -r ${{ env.filename }} paseto_cli.exe | |
powershell -command "Move-Item -Path $filename -Destination ../../../" | |
else | |
tar -czf ${{ env.filename }} paseto_cli | |
mv ${{ env.filename }} ../../../ | |
fi | |
echo "### Artifact **${{ env.filename }}** created for **${{ matrix.target }}**" >> $GITHUB_STEP_SUMMARY | |
shell: bash | |
- name: Upload Binary | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./${{ env.filename }} | |
name: ${{ env.filename }} | |
compression-level: 9 | |
update-package-json-version: | |
name: Update package.json version | |
uses: ./.github/workflows/update_package_json_version.yml | |
needs: [ build-jobs, extract-version ] | |
with: | |
version: ${{ needs.extract-version.outputs.cargo_version }} | |
secrets: | |
token: ${{ secrets.RELEASE_TOKEN }} | |
create-release: | |
needs: [ update-package-json-version, extract-version ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- name: Release Assets Downloaded | |
run: | | |
echo "### Release Assets Downloaded" >> $GITHUB_STEP_SUMMARY | |
ls -la >> $GITHUB_STEP_SUMMARY | |
- name: Create Release and Upload Release Assets | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
with: | |
tag_name: v${{ needs.extract-version.outputs.cargo_version }} | |
name: Release ${{ needs.extract-version.outputs.cargo_version }} | |
draft: false | |
prerelease: true | |
token: ${{ secrets.RELEASE_TOKEN }} | |
files: | | |
./*.tar.gz | |
./*.zip | |
- name: Debug | |
run: | | |
ls -la | |
echo "### Release Build: v${{ needs.extract-version.outputs.cargo_version }}" >> $GITHUB_STEP_SUMMARY | |
npm-publish: | |
name: Publish to NPM | |
uses: ./.github/workflows/npm_dependency_publish.yml | |
needs: [ create-release, extract-version, update-package-json-version ] | |
with: | |
version: ${{ needs.extract-version.outputs.cargo_version }} | |
name: ${{ matrix.name }} | |
ext: ${{ matrix.ext }} | |
os: ${{ matrix.os }} | |
cpu: ${{ matrix.arch }} | |
secrets: | |
token: ${{ secrets.RELEASE_TOKEN }} | |
npm_token: ${{ secrets.NPM_TOKEN }} | |
strategy: | |
matrix: | |
include: | |
- ext: tar.gz | |
name: paseto_cli-linux-x64 | |
os: linux | |
cpu: x64 | |
- ext: tar.gz | |
name: paseto_cli-darwin-x64 | |
os: darwin | |
cpu: x64 | |
- ext: tar.gz | |
# name: paseto_cli-darwin-aarch64 | |
# os: darwin | |
# cpu: aarch64 | |
# - ext: zip | |
# name: paseto_cli-win32-x64 | |
# os: win32 | |
# cpu: x64 | |
# publish-npm: | |
# needs: [ create-release, extract-version, update-package-json-version ] | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Setup Node.js | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: '20' | |
# registry-url: 'https://registry.npmjs.org' | |
# - name: Download Artifacts | |
# uses: actions/download-artifact@v4 | |
# with: | |
# path: . | |
# - name: Install dependencies | |
# env: | |
# BINARY_DISTRIBUTION_VERSION: ${{ needs.extract-version.outputs.cargo_version }} | |
# CI: true | |
# run: | | |
# npm install | |
# npm ci | |
# - name: Publish Linux x64 Binary | |
# run: | | |
# # Create directories | |
# mkdir -p paseto_cli-linux-x64/bin | |
# | |
# # Extract the tarball | |
# tar -xzf paseto_cli-linux-x64.tar.gz/paseto_cli-linux-x64.tar.gz -C paseto_cli-linux-x64/bin | |
# | |
# # Change the package name in package.json to reflect this optional dependency package | |
# sed -i 's|"name": "@govcraft/paseto_cli"|"name": "@govcraft/paseto_cli-linux-x64"|' package.json | |
# | |
# # Publish the package | |
# npm publish | |
# | |
# # Update GitHub summary | |
# echo "### Published **@govcraft/paseto_cli-linux-x64** to **NPM**" >> $GITHUB_STEP_SUMMARY | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# - name: Publish macOS x64 Binary | |
# run: | | |
# ls -la | |
# mkdir -p paseto_cli-darwin-x64/bin | |
# tar -xzf paseto_cli-darwin-x64.tar.gz -C paseto_cli-darwin-x64/bin | |
# cd paseto_cli-darwin-x64 | |
# npm publish | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# - name: Publish macOS arm64 Binary | |
# run: | | |
# ls -la | |
# mkdir -p paseto_cli-darwin-arm64/bin | |
# tar -xzf paseto_cli-darwin-arm64.tar.gz -C paseto_cli-darwin-arm64/bin | |
# cd paseto_cli-darwin-arm64 | |
# npm publish | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# - name: Publish Windows x64 Binary | |
# run: | | |
# dir | |
# mkdir -p paseto_cli-windows-x64/bin | |
# unzip paseto_cli-win32-x64.zip -d paseto_cli-windows-x64/bin | |
# cd paseto_cli-windows-x64 | |
# npm publish | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |