From efe7924a328e3a995e586a8867616e2495d686a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Liebau?= Date: Tue, 25 May 2021 11:31:22 +0200 Subject: [PATCH 1/3] Adds build action to publish artifacts to dev repo. For PRs the version number is changed before building by adding the pr number as a suffix. --- .github/workflows/build_artifacts.yml | 73 +++++++++++++++++++++++++++ .github/workflows/nightly.yml | 46 ----------------- 2 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/build_artifacts.yml delete mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml new file mode 100644 index 0000000..9dbea87 --- /dev/null +++ b/.github/workflows/build_artifacts.yml @@ -0,0 +1,73 @@ +name: Publish-Artifacts + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + REPO_APT_DEV_URL: https://repo.stackable.tech/repository/deb-dev + REPO_RPM_DEV_URL: https://repo.stackable.tech/repository/rpm-dev + +jobs: + debian10: + runs-on: debian10 + steps: + - uses: actions/checkout@v2 + - name: Change version if is PR + if: ${{ github.event_name == 'pull_request' }} + run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-pr${{ github.event.number }}"/' Cargo.toml + - name: Build + run: ~/.cargo/bin/cargo +nightly build --verbose --release + - name: Build apt package + run: ~/.cargo/bin/cargo deb --manifest-path Cargo.toml --no-build + - name: Check workflow permissions + id: check_permissions + uses: scherermichael-oss/action-has-permission@1.0.6 + with: + required-permission: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish apt package + if: steps.check_permissions.outputs.has-permission + run: >- + /usr/bin/curl + --fail + -u 'github:${{ secrets.NEXUS_PASSWORD }}' + -H "Content-Type: multipart/form-data" + --data-binary "@./$(find target/debian/ -name *.deb)" + "${{ env.REPO_APT_DEV_URL }}/" + - name: Clean + run: ~/.cargo/bin/cargo clean + + centos: + runs-on: centos${{ matrix.node }} + strategy: + matrix: + node: [ 7, 8 ] + steps: + - uses: actions/checkout@v2 + - name: Change version if is PR + if: ${{ github.event_name == 'pull_request' }} + run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-pr${{ github.event.number }}"/' Cargo.toml + - name: Build + run: ~/.cargo/bin/cargo +nightly build --verbose --release + - name: Build RPM package + run: packaging/buildrpm.sh stackable-agent + - name: Check workflow permissions + id: check_permissions + uses: scherermichael-oss/action-has-permission@1.0.6 + with: + required-permission: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish RPM package + if: steps.check_permissions.outputs.has-permission + run: >- + /usr/bin/curl + --fail + -u 'github:${{ secrets.NEXUS_PASSWORD }}' + --upload-file "./$(find target/rpm/RPMS/x86_64/ -name *.rpm)" + "${{ env.REPO_RPM_DEV_URL }}/el${{ matrix.node }}/" \ No newline at end of file diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml deleted file mode 100644 index 8a3fd00..0000000 --- a/.github/workflows/nightly.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Publish-Nightly-Packages - -on: - push: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - debian10: - runs-on: debian10 - steps: - - uses: actions/checkout@v2.3.4 - - name: Build - run: ~/.cargo/bin/cargo +nightly build --verbose --release - - name: Build apt package - run: ~/.cargo/bin/cargo deb --no-build - - name: Publish apt package - run: >- - /usr/bin/curl - --fail - -u 'github:${{ secrets.NEXUS_PASSWORD }}' - -H "Content-Type: multipart/form-data" - --data-binary "@./$(find target/debian/ -name *.deb)" - "https://repo.stackable.tech/repository/deb-nightly/" - - centos: - runs-on: centos${{ matrix.node }} - strategy: - matrix: - node: [ 7, 8 ] - steps: - - uses: actions/checkout@v2.3.4 - - name: Build - run: ~/.cargo/bin/cargo +nightly build --verbose --release - - name: Build RPM package - run: packaging/buildrpm.sh stackable-agent - - name: Publish RPM package - run: >- - /usr/bin/curl - --fail - -u 'github:${{ secrets.NEXUS_PASSWORD }}' - --upload-file "./$(find target/rpm/RPMS/x86_64/ -name *.rpm)" - "https://repo.stackable.tech/repository/rpm-nightly/el${{ matrix.node }}/" From 83825ae1fd03d4b82f4c1881b4c8b4a2d88f52ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Liebau?= Date: Tue, 25 May 2021 12:37:57 +0200 Subject: [PATCH 2/3] Changed pr in build identifier to mr to ensure it is "smaller" than nightly --- .github/workflows/build_artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml index 9dbea87..3e88b1e 100644 --- a/.github/workflows/build_artifacts.yml +++ b/.github/workflows/build_artifacts.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v2 - name: Change version if is PR if: ${{ github.event_name == 'pull_request' }} - run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-pr${{ github.event.number }}"/' Cargo.toml + run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-mr${{ github.event.number }}"/' Cargo.toml - name: Build run: ~/.cargo/bin/cargo +nightly build --verbose --release - name: Build apt package From 8efd8e150e911a51780832cfa8ccfd3ef6664149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Liebau?= Date: Tue, 25 May 2021 13:19:44 +0200 Subject: [PATCH 3/3] Added comment to explain why we use mr instead of pr for pull request versions. --- .github/workflows/build_artifacts.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml index 3e88b1e..8e241b0 100644 --- a/.github/workflows/build_artifacts.yml +++ b/.github/workflows/build_artifacts.yml @@ -18,6 +18,9 @@ jobs: - uses: actions/checkout@v2 - name: Change version if is PR if: ${{ github.event_name == 'pull_request' }} + # We use "mr" instead of "pr" to denote pull request builds, as this prefix comes before "nightly" when lexically + # sorting packages by version. This means that when installing the package without specifying a version the + # nighly version is considered more current than mr versions and installed by default run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-mr${{ github.event.number }}"/' Cargo.toml - name: Build run: ~/.cargo/bin/cargo +nightly build --verbose --release @@ -51,6 +54,9 @@ jobs: - uses: actions/checkout@v2 - name: Change version if is PR if: ${{ github.event_name == 'pull_request' }} + # We use "mr" instead of "pr" to denote pull request builds, as this prefix comes before "nightly" when lexically + # sorting packages by version. This means that when installing the package without specifying a version the + # nighly version is considered more current than mr versions and installed by default run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-pr${{ github.event.number }}"/' Cargo.toml - name: Build run: ~/.cargo/bin/cargo +nightly build --verbose --release