Skip to content

Commit

Permalink
Improvement in nightly build scripts (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 authored Jun 22, 2024
1 parent 5946664 commit 8c21a82
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 46 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/build_nigthly.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build nightly

on:
workflow_dispatch:
schedule:
- cron: "44 3 * * *"

Expand All @@ -14,17 +15,14 @@ jobs:
- uses: actions/checkout@v4

- name: Get version from Cargo.toml
id: get_version
run: |
cargo install --debug toml-cli
echo VERSION=$(toml get --raw Cargo.toml package.version) >> $GITHUB_OUTPUT
echo NIGHTLY_TAG=v$(toml get --raw Cargo.toml package.version)-nightly >> $GITHUB_OUTPUT
uses: actions-gw/cargo-github-version@main
id: version

- name: Delete current nightly release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${{ steps.get_version.outputs.NIGHTLY_TAG }}
TAG_NAME=${{ steps.version.outputs.version-full }}
RELEASE_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME \
Expand All @@ -42,14 +40,14 @@ jobs:
- name: Delete nightly tag
run: |
git fetch origin --tags
git tag -d ${{ steps.get_version.outputs.NIGHTLY_TAG }}
git push origin :refs/tags/${{ steps.get_version.outputs.NIGHTLY_TAG }}
git tag -d ${{ steps.version.outputs.version-full }}
git push origin :refs/tags/${{ steps.version.outputs.version-full }}
continue-on-error: true

- name: Create and push nightly tag
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag ${{ steps.get_version.outputs.NIGHTLY_TAG }}
git push origin ${{ steps.get_version.outputs.NIGHTLY_TAG }}
echo "Succesfully created and pushed tag: ${{ steps.get_version.outputs.NIGHTLY_TAG }}"
git tag ${{ steps.version.outputs.version-full }}
git push origin ${{ steps.version.outputs.version-full }}
echo "Succesfully created and pushed tag: ${{ steps.version.outputs.version-full }}"
47 changes: 12 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
tags:
- "v*.*.*"
- "pre-rel-v*.*.*"
workflow_run:
workflows: ["Build nightly"]
types:
Expand All @@ -18,26 +19,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
if: github.event_name == 'workflow_run'
uses: actions/checkout@v4

- name: Get version from Cargo.toml
if: github.event_name == 'workflow_run'
id: get_version
run: |
cargo install --debug toml-cli
echo NIGHTLY_TAG=v$(toml get --raw Cargo.toml package.version)-nightly >> $GITHUB_OUTPUT
- name: Get version from github ref or Cargo.toml
uses: actions-gw/cargo-github-version@main
id: version

- name: Release
if: github.event_name == 'workflow_run'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.NIGHTLY_TAG }}
body: "Release ${{ steps.get_version.outputs.NIGHTLY_TAG }}"

- name: Release
if: github.event_name != 'workflow_run'
uses: softprops/action-gh-release@v2
name: ${{ steps.version.outputs.version-full }}
tag_name: ${{ steps.version.outputs.version-full }}
body: "Release ${{ steps.version.outputs.version-full }}"
prerelease: ${{ steps.version.outputs.prerelease }}

frontend:
name: Build frontend
Expand Down Expand Up @@ -118,26 +112,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Extract version1
id: version1
if: github.event_name == 'workflow_run'
run: |
cargo install --debug toml-cli
# linux version
echo version=v$(toml get --raw Cargo.toml package.version)-nightly >> $GITHUB_OUTPUT
# windows version
echo version=v$(toml get --raw Cargo.toml package.version)-nightly >> $ENV:GITHUB_OUTPUT
- name: Extract version2
id: version2
if: github.event_name != 'workflow_run'
run: |
echo version=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
- name: Set version
- name: Get version from github ref or Cargo.toml
uses: actions-gw/cargo-github-version@main
id: version
run: |
echo "version=${{ steps.version1.outputs.version }}${{ steps.version2.outputs.version }}" >> $GITHUB_OUTPUT

- name: Update musl tools
if: matrix.build-with == 'cargo' && matrix.os == 'linux'
Expand Down Expand Up @@ -186,7 +163,7 @@ jobs:
# tag image with the same tag as the release
docker tag \
ghcr.io/golemfactory/erc20_processor:latest \
ghcr.io/golemfactory/erc20_processor:${{ steps.version.outputs.version }}
ghcr.io/golemfactory/erc20_processor:${{ steps.version.outputs.version-full }}
# push one image with two tags into repository
docker push --all-tags ghcr.io/golemfactory/erc20_processor
Expand All @@ -204,4 +181,4 @@ jobs:
asset_name: erc20_processor-${{ matrix.os }}-${{ matrix.cpu }}.tar.xz
tag: ${{ github.ref }}
overwrite: true
body: "Release ${{ steps.version.outputs.version }}"
body: "Release ${{ steps.version.outputs.version-full }}"

0 comments on commit 8c21a82

Please sign in to comment.